Skip to content
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

#372 flash:multipartTrailingLinebreak option #376

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 dist/FileAPI.flash.swf
Binary file not shown.
36 changes: 34 additions & 2 deletions dist/FileAPI.html5.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! FileAPI 2.0.19 - BSD | git://github.com/mailru/FileAPI.git
/*! FileAPI 2.0.20 - BSD | git://github.com/mailru/FileAPI.git
* FileAPI — a set of javascript tools for working with files. Multiupload, drag'n'drop and chunked file upload. Images: crop, resize and auto orientation by EXIF.
*/

Expand Down Expand Up @@ -286,7 +286,7 @@
* FileAPI (core object)
*/
api = {
version: '2.0.19',
version: '2.0.20',

cors: false,
html5: true,
Expand Down Expand Up @@ -3404,6 +3404,38 @@
callback('not_support_camera');
};

Camera.checkAlreadyCaptured = (function () {
var mediaDevices = navigator.mediaDevices,
MediaStreamTrack = window.MediaStreamTrack,
navigatorEnumerateDevices = navigator.enumerateDevices,
enumerateDevices;

if (mediaDevices && mediaDevices.enumerateDevices) {
enumerateDevices = function (callback) {
mediaDevices.enumerateDevices().then(callback);
};
} else if (MediaStreamTrack && MediaStreamTrack.getSources) {
enumerateDevices = MediaStreamTrack.getSources.bind(MediaStreamTrack);
} else if (navigatorEnumerateDevices) {
enumerateDevices = navigatorEnumerateDevices.bind(navigator);
} else {
enumerateDevices = function (fn) {
fn([]);
};
}

return function (callback) {
enumerateDevices(function (devices) {
var deviceExists = devices.some(function (device) {
return (device.kind === 'videoinput' || device.kind === 'video') && device.label;
});

callback(deviceExists);
});
};

})();


/**
* @class FileAPI.Camera.Shot
Expand Down
6 changes: 3 additions & 3 deletions dist/FileAPI.html5.min.js

Large diffs are not rendered by default.

36 changes: 34 additions & 2 deletions dist/FileAPI.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! FileAPI 2.0.19 - BSD | git://github.com/mailru/FileAPI.git
/*! FileAPI 2.0.20 - BSD | git://github.com/mailru/FileAPI.git
* FileAPI — a set of javascript tools for working with files. Multiupload, drag'n'drop and chunked file upload. Images: crop, resize and auto orientation by EXIF.
*/

Expand Down Expand Up @@ -286,7 +286,7 @@
* FileAPI (core object)
*/
api = {
version: '2.0.19',
version: '2.0.20',

cors: false,
html5: true,
Expand Down Expand Up @@ -3404,6 +3404,38 @@
callback('not_support_camera');
};

Camera.checkAlreadyCaptured = (function () {
var mediaDevices = navigator.mediaDevices,
MediaStreamTrack = window.MediaStreamTrack,
navigatorEnumerateDevices = navigator.enumerateDevices,
enumerateDevices;

if (mediaDevices && mediaDevices.enumerateDevices) {
enumerateDevices = function (callback) {
mediaDevices.enumerateDevices().then(callback);
};
} else if (MediaStreamTrack && MediaStreamTrack.getSources) {
enumerateDevices = MediaStreamTrack.getSources.bind(MediaStreamTrack);
} else if (navigatorEnumerateDevices) {
enumerateDevices = navigatorEnumerateDevices.bind(navigator);
} else {
enumerateDevices = function (fn) {
fn([]);
};
}

return function (callback) {
enumerateDevices(function (devices) {
var deviceExists = devices.some(function (device) {
return (device.kind === 'videoinput' || device.kind === 'video') && device.label;
});

callback(deviceExists);
});
};

})();


/**
* @class FileAPI.Camera.Shot
Expand Down
6 changes: 3 additions & 3 deletions dist/FileAPI.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions flash/core/src/net/inspirit/MultipartURLLoader.as
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
public class MultipartURLLoader extends EventDispatcher
{
public static var BLOCK_SIZE:uint = 64 * 1024;
public static var addTrailingLineBreak:Boolean = false;

private var _loader:URLLoader;
private var _boundary:String;
Expand Down Expand Up @@ -328,6 +329,9 @@
{
postData = BOUNDARY(postData);
postData = DOUBLEDASH(postData);
if (addTrailingLineBreak) {
postData = LINEBREAK(postData);
}
return postData;
}

Expand Down
40 changes: 26 additions & 14 deletions flash/core/src/ru/mail/controller/AppController.as
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ru.mail.controller
{
import by.blooddy.crypto.Base64;

import flash.display.Graphics;
import flash.display.Sprite;
import flash.display.Stage;
Expand All @@ -16,7 +16,9 @@ package ru.mail.controller
import flash.system.Security;
import flash.utils.Timer;
import flash.utils.setTimeout;


import net.inspirit.MultipartURLLoader;

import ru.mail.commands.LoadFileCommand;
import ru.mail.commands.UploadCommand;
import ru.mail.commands.textloader.SimpleTextLoader;
Expand Down Expand Up @@ -93,6 +95,22 @@ package ru.mail.controller
initView(graphicContext);

// parse flashvars
setupOptions(options);

setupChain();
configureListeners();

// check ping and complete initialisation
completeInitialization(options);
}

//===================================================
//
// Initialization
//
//===================================================

private function setupOptions(options):void {
_options = options;
JSCaller.callback = getJsFunctionName(options, JSCaller.callback);
// logger
Expand All @@ -107,7 +125,7 @@ package ru.mail.controller
JSCaller.flashId = options["flashId"];
}

// use camera
// use camera
// options["useCamera"], if not false, contains url to camera swf
_model.useCamera = options["useCamera"];
if (_model.useCamera && _model.useCamera !== 'false') {
Expand All @@ -118,19 +136,13 @@ package ru.mail.controller
_model.timeout = options["timeout"];
LoggerJS.log("timeout="+_model.timeout);

setupChain();
configureListeners();

// check ping and complete initialisation
completeInitialization(options);
if (options["multipartTrailingLinebreak"] && options["multipartTrailingLinebreak"] !== 'false') {
// set option to add linebreak at the end of multipart upload
MultipartURLLoader.addTrailingLineBreak = true;
}
LoggerJS.log("MultipartURLLoader.addTrailingLineBreak is " + MultipartURLLoader.addTrailingLineBreak);
}

//===================================================
//
// Initialization
//
//===================================================

/**
* We need transparent sprite to listen to mouseEvents
* JS places it over its button
Expand Down
2 changes: 1 addition & 1 deletion lib/FileAPI.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
* FileAPI (core object)
*/
api = {
version: '2.0.19',
version: '2.0.20',

cors: false,
html5: true,
Expand Down