Skip to content

Commit 8254f97

Browse files
committed
Merge pull request #67 from im-saxo/master
flash upload error http status
2 parents 562dc54 + 6e16ca6 commit 8254f97

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

FileAPI.flash.swf

-26.2 KB
Binary file not shown.

flash/src/ru/mail/commands/UploadFileCommand.as

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package ru.mail.commands
2222
public class UploadFileCommand extends AbstractUploadFileCommand
2323
{
2424
private var fileRef:FileReference;
25+
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
2526

2627
public function UploadFileCommand(fileRef:FileReference, url:String, headers:Object, uploadPostData:Object, uploadDataFieldName:String)
2728
{
@@ -103,7 +104,8 @@ package ru.mail.commands
103104
private function onHTTPStatus(event:HTTPStatusEvent):void
104105
{
105106
trace ("onHTTPStatus", event);
106-
LoggerJS.log("fileReference.upload HTTPStatusEvent: " +event.status)
107+
LoggerJS.log("fileReference.upload HTTPStatusEvent: " +event.status);
108+
status = event.status.toString();
107109
dispatchEvent(new TextEvent("httpStatus", false, false, event.status.toString() ) );
108110
}
109111

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

122124
trace ("onError", event);
123-
complete(false, null, new ErrorVO(event.toString(), errorType) );
125+
complete(false, null, new ErrorVO(event.toString(), errorType, status) );
124126
}
125127

126128
private function onProgress(event:ProgressEvent):void

flash/src/ru/mail/commands/UploadImageCommand.as

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package ru.mail.commands
2424
private var _files:Object;
2525
private var _totalSize:int = 0;
2626
private var _loader:MultipartURLLoader;
27+
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
2728

2829
public function UploadImageCommand(files:Object, url:String, headers:Object, uploadPostData:Object)
2930
{
@@ -130,7 +131,8 @@ package ru.mail.commands
130131
private function onHTTPStatus(event:HTTPStatusEvent):void
131132
{
132133
trace ("onHTTPStatus", event);
133-
LoggerJS.log("urlloader.upload onHTTPStatus: " +event.toString());
134+
LoggerJS.log("urlloader.upload onHTTPStatus: " +event.status);
135+
status = event.status.toString();
134136
dispatchEvent(new TextEvent("httpStatus", false, false, event.status.toString() ) );
135137
}
136138

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

149151
trace ("onError", event);
150-
complete(false, null, new ErrorVO(event.toString(), errorType) );
152+
complete(false, null, new ErrorVO(event.toString(), errorType, status) );
151153
}
152154

153155
private function onProgress(event:ProgressEvent):void

flash/src/ru/mail/controller/AppController.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ package ru.mail.controller
597597
if (event.error.error.indexOf("#2038") > -1) {
598598
_model.hasError = true;
599599
}
600-
_jsCaller.callJS( callback, {type:"error", message:event.error.getError() } );
600+
_jsCaller.callJS( callback, {type:"error", message:event.error.getError(), status:event.error.httpStatus } );
601601
}
602602

603603
uploadCommand.dispose();

flash/src/ru/mail/data/vo/ErrorVO.as

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ package ru.mail.data.vo
1515
public var errorType:String = "error";
1616
public var errorID:String = "";
1717
public var errorMessage:String = "";
18+
public var httpStatus:String = '';
1819

19-
public function ErrorVO(error:String, errorType:String = null)
20+
public function ErrorVO(error:String, errorType:String = null, httpStatus:String = null)
2021
{
2122
super();
2223
parseError(error);
2324
if (errorType) {
2425
this.errorType = errorType;
2526
}
27+
if (httpStatus) {
28+
this.httpStatus = httpStatus;
29+
}
2630
}
2731

2832
public function parseError(str:String):void {

lib/FileAPI.Flash.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* FileAPI fallback to Flash
33
*
4-
* @flash-developer "Vladimer Demidov" <v.demidov@corp.mail.ru>
4+
* @flash-developer "Vladimir Demidov" <v.demidov@corp.mail.ru>
55
*/
66
(function (api, window, document){
77
api.support.flash = (function (){
@@ -463,7 +463,7 @@
463463
_this.end(evt.status || 200);
464464
}
465465
else if( type == 'abort' || type == 'error' ){
466-
_this.end(0, evt.message);
466+
_this.end(evt.status || 0, evt.message);
467467
_unwrap(upload);
468468
}
469469
})

0 commit comments

Comments
 (0)