首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MinIO上载名称包含特殊字符的文件会发出HTTP403禁止

问MinIO上载名称包含特殊字符的文件会发出HTTP403禁止
EN

Stack Overflow用户
提问于 2021-09-15 20:32:26
回答 1查看 180关注 0票数 0

将对象从.net 403客户端上载到名称中包含特殊字符的MinIO时,会发出HTTP403。

此对象失败: old_me_bold+19(1).jpg此对象正常: old_me_bold19.jpg

消息是:我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。

什么是MinIO的突破口?

EN

回答 1

Stack Overflow用户

发布于 2021-09-21 17:22:12

对Url进行编码也不起作用。我还尝试了PresignedPutObjectAsync来创建一个已经签名的tmp Url,然后我使用HttpClient进行了PUT,结果相同。为了测试这种方式是否有效,我删除了文件名中的特殊字符,这样客户端就可以将文件发送到MinIO。

此代码失败:

代码语言:javascript
复制
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的任何其他文件,如果名称不包含字符(),则上载始终有效。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69199464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档