将对象从.net 403客户端上载到名称中包含特殊字符的MinIO时,会发出HTTP403。
此对象失败: old_me_bold+19(1).jpg此对象正常: old_me_bold19.jpg
消息是:我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。
什么是MinIO的突破口?
发布于 2021-09-21 17:22:12
对Url进行编码也不起作用。我还尝试了PresignedPutObjectAsync来创建一个已经签名的tmp Url,然后我使用HttpClient进行了PUT,结果相同。为了测试这种方式是否有效,我删除了文件名中的特殊字符,这样客户端就可以将文件发送到MinIO。
此代码失败:
public async System.Threading.Tasks.Task PutAttachementAsync(
Attachment attachment,
string bukectName,
string objectName,
string attachmentType = "application/octet-stream")
{
using (HttpClient client = new HttpClient())
{
var minioClient = GetMinioClient();
client.BaseAddress = new Uri(Config.Instance.GetConfig("MinIOURL"));
var tempFileName = CreateAttachmentTempFile(attachment, out bool virusScanResult);
if (!virusScanResult)
return;
using (FileStream str = new FileStream(tempFileName.FileAttachmentPath, FileMode.Open))
{
try
{
String signedTMPUrl = await minioClient.PresignedPutObjectAsync(bukectName, objectName, 60 * 60 * 24);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(attachmentType));
HttpResponseMessage response = await client.PutAsync(signedTMPUrl, new StreamContent(str));
if (response.IsSuccessStatusCode)
{
Log.InfoFormat("Request Message Information:- \n\n" + response.RequestMessage + "\n");
Log.InfoFormat("Response Message Header \n\n" + response.Content.Headers + "\n");
}
else
{
Log.InfoFormat("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}
}
catch (MinioException e)
{
Log.Error("Error occurred: " + e.Message);
}
}
}
}该代码是从IIS中承载的ASP.Net应用程序运行的。我想知道IIS是否在消息发送到MinIO之前向标头中注入了什么东西。
我发送到MinIO的任何其他文件,如果名称不包含字符(),则上载始终有效。
https://stackoverflow.com/questions/69199464
复制相似问题