flex - File Upload with Adobe Air -
i'm trying upload file flex minus.com
the api reference explain upload example:
post /api/v2/folders/0fqhjakl/files?bearer_token=[token] http/1.1 host: minus.com content-type: multipart/form-data; boundary=----webkitformboundaryxecy8varbqixzw4f accept-charset: utf-8,*;q=0.5
------webkitformboundaryayaohdwfizxzb8oe content-disposition: form-data; name="file"; filename="test.txt" content-type: text/plain
test ------webkitformboundaryayaohdwfizxzb8oe content-disposition: form-data; name="filename"
test.txt ------webkitformboundaryayaohdwfizxzb8oe content-disposition: form-data; name="caption"
testfile ------webkitformboundaryayaohdwfizxzb8oe--
my as3 code is:
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] 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 ioerrorevent...
try send "multipart/form-data".
var header:urlrequestheader = new urlrequestheader("enctype", "multipart/form-data"); request.requestheaders.push(header);
Comments
Post a Comment