[英]File Upload with Adobe Air
I'm trying to upload a file with Flex to Minus.com 我正在尝试使用Flex将文件上传到Minus.com
The API Reference explain the upload with this example: API参考通过以下示例说明了上传:
POST /api/v2/folders/0FQHJakL/files?bearer_token=[token] HTTP/1.1 Host: minus.com Content-Type: multipart/form-data;
POST / api / v2 / folders / 0FQHJakL / files?bearer_token = [token] HTTP / 1.1主机:minus.com内容类型:multipart / form-data; boundary=----WebKitFormBoundaryxECY8varBqIXZW4f Accept-Charset: UTF-8,*;q=0.5
boundary = ---- WebKitFormBoundaryxECY8varBqIXZW4f Accept-Charset:UTF-8,*; q = 0.5
------WebKitFormBoundaryAYAOHDWfizxZB8OE Content-Disposition: form-data;
------ WebKitFormBoundaryAYAOHDWfizxZB8OE内容处置:表格数据; name="file";
name =“文件”; filename="test.txt" Content-Type: text/plain
filename =“ test.txt”内容类型:文本/纯文本
test ------WebKitFormBoundaryAYAOHDWfizxZB8OE Content-Disposition: form-data;
测试------ WebKitFormBoundaryAYAOHDWfizxZB8OE内容处置:表格数据; name="filename"
name =“文件名”
test.txt ------WebKitFormBoundaryAYAOHDWfizxZB8OE Content-Disposition: form-data;
test.txt ------ WebKitFormBoundaryAYAOHDWfizxZB8OE内容处置:form-data; name="caption"
name =“标题”
testfile ------WebKitFormBoundaryAYAOHDWfizxZB8OE--
测试文件------ WebKitFormBoundaryAYAOHDWfizxZB8OE--
my AS3 Code is: 我的AS3代码是:
var params:URLVariables = new URLVariables();
params.caption = object.offlineFiles[0].name;
params.filename = object.offlineFiles[0].name;
params.bearer_token=appModel.loginData.access_token;
var fr:File = (object.offlineFiles[0] as File);
fr.addEventListener(IOErrorEvent.IO_ERROR,uploadError_Handler);
var request:URLRequest = new URLRequest("http://minus.com/api/v2/folders/......./files");
request.data = params;
request.method = URLRequestMethod.POST;
fr.upload(request,"file");
but I get an IOErrorEvent... 但我得到了IOErrorEvent ...
Try to send it with "multipart/form-data". 尝试将其与“ multipart / form-data”一起发送。
var header:URLRequestHeader = new URLRequestHeader("enctype", "multipart/form-data");
request.requestHeaders.push(header);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.