我正在尝试使用 azure storage blob 在其上放置一个项目。它适用于 PDF、MP3,但是当我上传IMAGE文件(或 TXT 文件)时,文件已更改。
当我下载 pdf 或 mp3 时,该文件是可读的。但是对于图像,它说它已损坏......但是 TXT 文件是可读的,但内容被webkitfromboundary包围
我认为这就是为什么图像不起作用的原因......
例子:
TXT 文件hello word
只有 ->
------WebKitFormBoundary3rxc8zHbnz4expeP
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
hello word
------WebKitFormBoundary3rxc8zHbnz4expeP--
所以我想这就是图像不起作用的原因
所以这是我的上传(来自angularJS)---我使用https://github.com/danialfarid/ng-file-upload
Upload.upload
url: url
method: 'PUT'
headers: head
file: file
.success (data, status, headers, config) ->
console.log("SUCCES!!!")
- 的值head
(对于文本文件)
{"x-ms-version":"2014-02-14","x-ms-blob-type":"BlockBlob","x-ms-date":"2015-11-06 10:02:24 GMT","Authorization":"SharedKey generate_key","Content-Type":"text/plain"}
当然,当这是图像时,内容类型会发生变化(它需要file.type)
如果有帮助,这是来自网络页面的请求标头->
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:fr,en-US;q=0.8,en;q=0.6
Connection:keep-alive
Content-Length:214
Content-Type:application/json;charset=utf-8
Host:myaccount.blob.core.windows.net
Origin:http://localhost:9000
Referer:http://localhost:9000/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
和请求有效载荷- >
------WebKitFormBoundary3rxc8zHbnz4expeP
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
------WebKitFormBoundary3rxc8zHbnz4expeP--
那么,有人有想法吗?