diff --git a/.gitignore b/.gitignore index b43207d1..feefd2f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,6 @@ node_modules -tests/files/BigJPG.jpg -tests/files/big.jpg dist/FileAPI.html5ok.js dist/FileAPI.html5ok.min.js dist/FileAPI.ok.js dist/FileAPI.ok.min.js .idea - diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..191381ee --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +.git \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 98f49b4b..1fdfc355 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: - - 0.10 + - 4.5 before_script: - npm install -g grunt-cli diff --git a/Gruntfile.js b/Gruntfile.js index dfc52bc8..9276a4b6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,6 +10,7 @@ module.exports = function (grunt) { 'Gruntfile.js' , 'lib/**/*.js' , 'plugins/jquery.fileapi.js' + , 'node/**/*.js' ], options: { @@ -66,7 +67,7 @@ module.exports = function (grunt) { options: { timeout: 5 * 60 * 1000, // 5min files: { - '1px.gif': ['tests/files/1px.gif'] + '1px_gif': ['tests/files/1px.gif'] , 'big.jpg': ['tests/files/big.jpg'] , 'hello.txt': ['tests/files/hello.txt'] , 'image.jpg': ['tests/files/image.jpg'] @@ -84,7 +85,7 @@ module.exports = function (grunt) { ' * <%= pkg.description %>\n' + ' */\n\n', - footer: 'if( typeof define === "function" && define.amd ){ define("FileAPI", [], function (){ return FileAPI; }); }' + footer: 'if( typeof define === "function" && define.amd ){ define("<%= pkg.jam.name %>", [], function (){ return FileAPI; }); }' }, all: { @@ -130,7 +131,7 @@ module.exports = function (grunt) { mxmlc: { core: { options: { - rawConfig: '-static-link-runtime-shared-libraries=true -compiler.debug=true' + + rawConfig: '-target-player=10.1 -static-link-runtime-shared-libraries=true -compiler.debug=false' + ' -library-path+=flash/core/lib/blooddy_crypto.swc -library-path+=flash/core/lib/EnginesLibrary.swc' }, files: { @@ -139,7 +140,7 @@ module.exports = function (grunt) { }, image: { options: { - rawConfig: '-static-link-runtime-shared-libraries=true -compiler.debug=true' + + rawConfig: '-static-link-runtime-shared-libraries=true -compiler.debug=false' + ' -library-path+=flash/image/lib/blooddy_crypto.swc' }, files: { @@ -148,7 +149,7 @@ module.exports = function (grunt) { }, camera: { options: { - rawConfig: '-static-link-runtime-shared-libraries=true -compiler.debug=true' + rawConfig: '-static-link-runtime-shared-libraries=true -compiler.debug=false' }, files: { 'dist/<%= pkg.exportName %>.flash.camera.swf': ['flash/camera/src/FileAPI_flash_camera.as'] @@ -182,12 +183,23 @@ module.exports = function (grunt) { // "npm build" runs these tasks grunt.registerTask('prepare-test-files', function (){ - if (!grunt.file.exists('tests/files/big.jpg')) { + // big.jpg added to git + /*if (!grunt.file.exists('tests/files/big.jpg')) { grunt.task.run('curl'); - } + }*/ + }); + + grunt.registerTask('express', 'Start a custom web server.', function() { + var done = this.async(); + + require('./node/server.js').createServer(8000, function () { + done(); + }); }); - grunt.registerTask('tests', ['jshint', 'concat', 'connect:server','prepare-test-files', 'qunit']); + grunt.registerTask('server', ['connect:server', 'express']); + grunt.registerTask('dev', ['concat', 'server', 'watch']); + grunt.registerTask('tests', ['jshint', 'concat', 'server', 'prepare-test-files', 'qunit']); grunt.registerTask('build', ['version', 'concat', 'uglify']); grunt.registerTask('build-all', ['build', 'mxmlc']); grunt.registerTask('default', ['tests', 'build']); diff --git a/README.md b/README.md index 6be5394f..b5037a77 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@  ## FileAPI -A set of javascript tools for working with files. +A set of JavaScript tools for working with files. ### Get started @@ -371,6 +371,34 @@ var xhr = FileAPI.upload({ --- + +### uploadMethod`:String` +Request method, HTML5 only. + +```js +var xhr = FileAPI.upload({ + url: '...', + uploadMethod: 'PUT', + files: { .. }, +}); +``` + +--- + + +### uploadCredentials`:Boolean` +Pass credentials to upload request, HTML5 only. + +```js +var xhr = FileAPI.upload({ + url: '...', + uploadCredentials: false, + files: { .. }, +}); +``` + +--- + ### headers`:Object` Additional request headers, HTML5 only. @@ -385,6 +413,12 @@ var xhr = FileAPI.upload({ --- + +### cache`:Boolean` +Setting to true removes the default timestamp URL parameter. + +--- + ### files`:Object` Key-value object, `key` — post name, `value` — File or FileAPI.Image object. @@ -773,7 +807,7 @@ Resize image. * width — new image width * height — new image height -* strategy — enum: `min`, `max`, `preview`. By default `undefined`. +* strategy — enum: `min`, `max`, `preview`, `width`, `height`. By default `undefined`. ```js FileAPI.Image(imageFile) @@ -790,6 +824,14 @@ FileAPI.Image(imageFile) }) ; + +// Resize image on by fixed height. +FileAPI.Image(imageFile) + .resize(240, 'height') + .get(function (err/**String*/, img/**HTMLElement*/){ + + }) +; ``` --- @@ -979,8 +1021,8 @@ FileAPI.Camera.publish(el, function (err, cam/**FileAPI.Camera*/){ --- - -## Сonstants + +## Constants ### FileAPI.KB`:Number` @@ -1005,7 +1047,7 @@ FileAPI.Camera.publish(el, function (err, cam/**FileAPI.Camera*/){ ### FileAPI.each(obj`:Object|Array`, callback`:Function`[, thisObject`:Mixed`])`:void` -Iterate over a object or array, executing a function for each matched element. +Iterate over an object or array, executing a function for each matched element. * obj — array or object * callback — a function to execute for each element. @@ -1040,7 +1082,7 @@ Creates a new array with all elements that pass the test implemented by the prov
  • Chunked file upload (HTML5)
  • Upload one file: all browsers
  • - Working with Images: IE6+, FF 3.6+, Chrome 10+, Opera 11.1+, Safari 5.4+ + Working with Images: IE6+, FF 3.6+, Chrome 10+, Opera 11.1+, Safari 6+