Skip to content

Instantly share code, notes, and snippets.

@mani95lisa
Last active December 31, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mani95lisa/7912530 to your computer and use it in GitHub Desktop.
Save mani95lisa/7912530 to your computer and use it in GitHub Desktop.
//ActionScript3 upload file to qiniu.com
var u:URLRequest=new URLRequest('http://up.qiniu.com');
u.method=URLRequestMethod.POST;
u.requestHeaders=[new URLRequestHeader('enctype', 'multipart/form-data')];
var ur:URLVariables=new URLVariables();
ur.key='Your file name in qiniu.com';
ur.token='Your uptoken from server'; //Only this is required
ur['x:param'] = 'Your custom param and value';
u.data=ur;
f.upload(u, 'file'); //File or FileReference is both OK, but UploadDataFieldName must be 'file'
f.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadedHandler);
protected function uploadedHandler(event:DataEvent):void
{
trace(event.data); //{"hash":"File hash info","key":"Uploaded file name", "x:param":"Your custom param and value"}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment