w985341237
V2EX  ›  程序员

请教 springboot 对接 Azure 上传文件问题

By w985341237 at 2024 年 6 月 1 日 · 2144 次点击

我有个对接 Azure 的问题想请教一下。我在 maven 里引了 azure-storage-blob ,也拿到了 sasToken ,构建 blobClient 调用 isExists 和 downloadToFile 都没问题。 但是调用 upload 上传文件就一直报错,错误是

Caused by: com.azure.storage.blob.models.BlobStorageException: Status code 400, "<Error>InvalidHeaderValue<Message>The value for one of the HTTP headers is not in the correct format. RequestId:89202da3-801a-000d-5cce-b3b7f3000000 Time:2024-06-01T02:48:29.2368676Z</Message><HeaderName>Content-Length</HeaderName><HeaderValue>24</HeaderValue></Error>"

很奇怪,但是我如果不用 sdk ,直接用 Azcopy 是可以上传成功的。不知道各位有没有遇见过类似问题

2 条回复  •  2024-06-01 19:27:52 +08:00
SculptureSand
   2
SculptureSand  
   2024 年 6 月 1 日
后端调用 SDK 签发 Azure 对象存储 URL ,前端(特指浏览器)PUT 上传?
可能是 Content-Type 的问题,前端会自动指定,后端要主动填一下
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
© 2026 V2EX · 41ms · 3.9.8.5