Skip to content

flash upload error http status #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified FileAPI.flash.swf
Binary file not shown.
6 changes: 4 additions & 2 deletions flash/src/ru/mail/commands/UploadFileCommand.as
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package ru.mail.commands
public class UploadFileCommand extends AbstractUploadFileCommand
{
private var fileRef:FileReference;
private var status:String = null; // httpStatus. in case of upload error we get httpStatus event followed by ioError event. add status to error event using this temp variable

public function UploadFileCommand(fileRef:FileReference, url:String, headers:Object, uploadPostData:Object, uploadDataFieldName:String)
{
Expand Down Expand Up @@ -103,7 +104,8 @@ package ru.mail.commands
private function onHTTPStatus(event:HTTPStatusEvent):void
{
trace ("onHTTPStatus", event);
LoggerJS.log("fileReference.upload HTTPStatusEvent: " +event.status)
LoggerJS.log("fileReference.upload HTTPStatusEvent: " +event.status);
status = event.status.toString();
dispatchEvent(new TextEvent("httpStatus", false, false, event.status.toString() ) );
}

Expand All @@ -120,7 +122,7 @@ package ru.mail.commands
LoggerJS.log("fileReference.upload onError: " +event.toString());

trace ("onError", event);
complete(false, null, new ErrorVO(event.toString(), errorType) );
complete(false, null, new ErrorVO(event.toString(), errorType, status) );
}

private function onProgress(event:ProgressEvent):void
Expand Down
6 changes: 4 additions & 2 deletions flash/src/ru/mail/commands/UploadImageCommand.as
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package ru.mail.commands
private var _files:Object;
private var _totalSize:int = 0;
private var _loader:MultipartURLLoader;
private var status:String = null; // httpStatus. in case of upload error we get httpStatus event followed by ioError event. add status to error event using this temp variable

public function UploadImageCommand(files:Object, url:String, headers:Object, uploadPostData:Object)
{
Expand Down Expand Up @@ -130,7 +131,8 @@ package ru.mail.commands
private function onHTTPStatus(event:HTTPStatusEvent):void
{
trace ("onHTTPStatus", event);
LoggerJS.log("urlloader.upload onHTTPStatus: " +event.toString());
LoggerJS.log("urlloader.upload onHTTPStatus: " +event.status);
status = event.status.toString();
dispatchEvent(new TextEvent("httpStatus", false, false, event.status.toString() ) );
}

Expand All @@ -147,7 +149,7 @@ package ru.mail.commands
LoggerJS.log("fileReference.upload onError: " +event.toString());

trace ("onError", event);
complete(false, null, new ErrorVO(event.toString(), errorType) );
complete(false, null, new ErrorVO(event.toString(), errorType, status) );
}

private function onProgress(event:ProgressEvent):void
Expand Down
2 changes: 1 addition & 1 deletion flash/src/ru/mail/controller/AppController.as
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ package ru.mail.controller
if (event.error.error.indexOf("#2038") > -1) {
_model.hasError = true;
}
_jsCaller.callJS( callback, {type:"error", message:event.error.getError() } );
_jsCaller.callJS( callback, {type:"error", message:event.error.getError(), status:event.error.httpStatus } );
}

uploadCommand.dispose();
Expand Down
6 changes: 5 additions & 1 deletion flash/src/ru/mail/data/vo/ErrorVO.as
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ package ru.mail.data.vo
public var errorType:String = "error";
public var errorID:String = "";
public var errorMessage:String = "";
public var httpStatus:String = '';

public function ErrorVO(error:String, errorType:String = null)
public function ErrorVO(error:String, errorType:String = null, httpStatus:String = null)
{
super();
parseError(error);
if (errorType) {
this.errorType = errorType;
}
if (httpStatus) {
this.httpStatus = httpStatus;
}
}

public function parseError(str:String):void {
Expand Down
4 changes: 2 additions & 2 deletions lib/FileAPI.Flash.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* FileAPI fallback to Flash
*
* @flash-developer "Vladimer Demidov" <v.demidov@corp.mail.ru>
* @flash-developer "Vladimir Demidov" <v.demidov@corp.mail.ru>
*/
(function (api, window, document){
api.support.flash = (function (){
Expand Down Expand Up @@ -463,7 +463,7 @@
_this.end(evt.status || 200);
}
else if( type == 'abort' || type == 'error' ){
_this.end(0, evt.message);
_this.end(evt.status || 0, evt.message);
_unwrap(upload);
}
})
Expand Down