Skip to content

Commit 35971ec

Browse files
committed
chore: rename to flow.js
1 parent 57595d6 commit 35971ec

27 files changed

+373
-1922
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ node_js:
33
- 0.1
44
env:
55
global:
6-
- secure: QnbopydTyvqD3CmNZa6Ppu68m7ug+HKXYOvWhcdbqWQryDHGzoMk/ehQjrFszAAO0s+4a//aMzlNJnZQW8wYxtXyA5RlPGl4Vbr9uhSeHNEgxBzgeqSD8+3ZjgE/ORmuds7jjPDStG50uotD+DubQKLiMe/vn9Ej9bArpZ2pGKk=
7-
- secure: GkU6vcxcmPtVo3nnMj+HGX+Hde1jU/ad/Un2Sexx0nBZzYd3d/A2HGdbd4NAtjioyucUCyHSYaG2n3yE+u16ucFDYBB9Wu1zlXynku39pSiDcz/pjh9mR7VBHg4VNGKqe5ZtU5udohFsOZMYTegqk5nw9yW6VgZzRa/1mWsg2YY=
6+
- SAUCE_USERNAME=aidaskk
7+
- SAUCE_ACCESS_KEY=6e96b47e-6665-4f69-beaa-085e5d5b6b9b
88
before_script:
99
- sh -e /etc/init.d/xvfb start
1010
- npm install --quiet -g grunt-cli karma

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- **singleFile** parameter added. Then enabled, uploaded file will replace current one.
2323

2424
## Breaking Changes
25-
25+
- **Resumable** was renamed to **Flow**
2626
- **ResumableFile.fileName** parameter renamed to **ResumableFile.name**
2727
- **Resumable.getOpt** method dropped, use Resumable.opts parameter instead if needed.
2828
- **Resumable.maxFiles**, **Resumable.minFileSize**, **Resumable.maxFileSize**,

Gruntfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module.exports = function(grunt) {
88
banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n'
99
},
1010
build: {
11-
src: 'src/resumable.js',
12-
dest: 'build/resumable.min.js'
11+
src: 'src/flow.js',
12+
dest: 'build/flow.min.js'
1313
}
1414
},
1515
coveralls: {

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Flow.js [![Build Status](https://travis-ci.org/resumable2/resumable.js.png)](https://travis-ci.org/resumable2/resumable.js) [![Coverage Status](https://coveralls.io/repos/resumable2/resumable.js/badge.png?branch=master)](https://coveralls.io/r/resumable2/resumable.js?branch=master)
1+
## Flow.js [![Build Status](https://travis-ci.org/flowjs/flow.js.png)](https://travis-ci.org/flowjs/flow.js) [![Coverage Status](https://coveralls.io/repos/flowjs/flow.js/badge.png?branch=master)](https://coveralls.io/r/flowjs/flow.js?branch=master)
22

33

44
Flow.js is a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API.

bower.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "resumable.js",
3-
"version": "2.0.0-beta",
4-
"main": "src/resumable.js",
2+
"name": "flow.js",
3+
"version": "2.0.0-beta2",
4+
"main": "src/flow.js",
55
"ignore": [
66
"**/.*",
77
"node_modules",

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
2-
"name": "resumable.js",
2+
"name": "flow.js",
33
"version": "2.0.0-beta",
4-
"description": "Resumable.js is a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API",
5-
"main": "resumable.js",
4+
"description": "Flow.js library implements html5 file upload and provides multiple simultaneous, stable, fault tolerant and resumable uploads.",
5+
"main": "src/flow.js",
66
"scripts": {
77
"test": "grunt test"
88
},
99
"repository": {
1010
"type": "git",
11-
"url": "git://github.com/resumable2/resumable.js.git"
11+
"url": "git://github.com/flowjs/flow.js.git"
1212
},
1313
"keywords": [
14+
"flow.js",
15+
"flow",
1416
"resumable.js",
1517
"file upload",
1618
"resumable upload",
@@ -19,12 +21,11 @@
1921
"javascript upload",
2022
"upload"
2123
],
22-
"author": "",
24+
"author": "Aidas Klimas",
2325
"license": "MIT",
24-
"gitHead": "75d9526a46767454ca304ad257d0cef448815f1a",
2526
"readmeFilename": "README.md",
2627
"bugs": {
27-
"url": "https://github.com/resumable2/resumable.js/issues"
28+
"url": "https://github.com/flowjs/flow.js/issues"
2829
},
2930
"devDependencies": {
3031
"grunt": "~0.4.1",

samples/Backend on PHP.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Sample server implementation in PHP
1+
# Sample server implementation in PHP
2+
3+
Take a look at flow.js php library https://github.com/flowjs/flow-php-server.
24

35
[Chris Gregory](http://online-php.com) has provided this sample implementation for PHP.
46

@@ -8,7 +10,7 @@ It's a sample implementation to illustrate chunking. It should probably not be u
810
<?php
911
/**
1012
* This is the implementation of the server side part of
11-
* Resumable.js client script, which sends/uploads files
13+
* Flow.js client script, which sends/uploads files
1214
* to a server in several chunks.
1315
*
1416
* The script receives the files in a standard way as if
@@ -123,8 +125,8 @@ function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) {
123125
//check if request is GET and the requested chunk exists or not. this makes testChunks work
124126
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
125127

126-
$temp_dir = 'temp/'.$_GET['resumableIdentifier'];
127-
$chunk_file = $temp_dir.'/'.$_GET['resumableFilename'].'.part'.$_GET['resumableChunkNumber'];
128+
$temp_dir = 'temp/'.$_GET['flowIdentifier'];
129+
$chunk_file = $temp_dir.'/'.$_GET['flowFilename'].'.part'.$_GET['flowChunkNumber'];
128130
if (file_exists($chunk_file)) {
129131
header("HTTP/1.0 200 Ok");
130132
} else
@@ -140,14 +142,14 @@ if (!empty($_FILES)) foreach ($_FILES as $file) {
140142

141143
// check the error status
142144
if ($file['error'] != 0) {
143-
_log('error '.$file['error'].' in file '.$_POST['resumableFilename']);
145+
_log('error '.$file['error'].' in file '.$_POST['flowFilename']);
144146
continue;
145147
}
146148

147149
// init the destination file (format <filename.ext>.part<#chunk>
148150
// the file is stored in a temporary directory
149-
$temp_dir = 'temp/'.$_POST['resumableIdentifier'];
150-
$dest_file = $temp_dir.'/'.$_POST['resumableFilename'].'.part'.$_POST['resumableChunkNumber'];
151+
$temp_dir = 'temp/'.$_POST['flowIdentifier'];
152+
$dest_file = $temp_dir.'/'.$_POST['flowFilename'].'.part'.$_POST['flowChunkNumber'];
151153

152154
// create the temporary directory
153155
if (!is_dir($temp_dir)) {
@@ -156,12 +158,12 @@ if (!empty($_FILES)) foreach ($_FILES as $file) {
156158

157159
// move the temporary file
158160
if (!move_uploaded_file($file['tmp_name'], $dest_file)) {
159-
_log('Error saving (move_uploaded_file) chunk '.$_POST['resumableChunkNumber'].' for file '.$_POST['resumableFilename']);
161+
_log('Error saving (move_uploaded_file) chunk '.$_POST['flowChunkNumber'].' for file '.$_POST['flowFilename']);
160162
} else {
161163

162164
// check if all the parts present, and create the final destination file
163-
createFileFromChunks($temp_dir, $_POST['resumableFilename'],
164-
$_POST['resumableChunkSize'], $_POST['resumableTotalSize']);
165+
createFileFromChunks($temp_dir, $_POST['flowFilename'],
166+
$_POST['flowChunkSize'], $_POST['flowTotalSize']);
165167
}
166168
}
167169
```

samples/Frontend in jQuery.md

+2-59
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,2 @@
1-
# Resumable.js front-end in jQuery
2-
[@steffentchr](http://twitter.com/steffentchr)
3-
4-
This library is originally built to work with [23 Video](http://www.23video.com), and the 23 uploader is a good example of:
5-
6-
* Selecing files or drag-dropping them in
7-
* Using events to build UI and progress bar
8-
* Pausing and Resuming uploads
9-
* Recovering uploads after browser crashes and even across different computers
10-
* Detecting file support from chunks, for example whether an upload is actually a video file
11-
* Building thumbnails from chunks to give better feedback during upload
12-
* Falling back to alternative upload options when Resumable.js is not supported.
13-
14-
There's [a free trial for 23 Video](http://www.23video.com/signup) if
15-
you want to see this in action, but the pieces are:
16-
17-
* Resumable.js itself.
18-
* [A piece of jQuery](http://reinvent.23video.com/resources/um/script/resumable-uploader.js), which sets up Resumable.js and glues it to the UI.
19-
* [An API methods](http://www.23developer.com/api/photo-redeem-upload-token) with support for Resumable.js chunks and feedback.
20-
* Finally, some HTML elements for the glue script to use.
21-
22-
```html
23-
<div class="resumable-drop" ondragenter="jQuery(this).addClass('resumable-dragover');" ondragend="jQuery(this).removeClass('resumable-dragover');" ondrop="jQuery(this).removeClass('resumable-dragover');">
24-
Drop video files here to upload or <a class="resumable-browse"><u>select from your computer</u></a>
25-
</div>
26-
27-
<div class="progress" style="display:none;">
28-
<table>
29-
<tr>
30-
<td width="100%"><div class="progress-container"><div class="progress-bar"></div></div></td>
31-
<td class="progress-text" nowrap="nowrap"></td>
32-
<td class="progress-pause" nowrap="nowrap">
33-
<a href="#" onclick="uploader.resumable.upload(); return(false);" class="progress-resume-link"><img src="/resources/um/graphics/uploader/resume.png" title="Resume upload" /></a>
34-
<a href="#" onclick="uploader.resumable.pause(); return(false);" class="progress-pause-link"><img src="/resources/um/graphics/uploader/pause.png" title="Pause upload" /></a>
35-
</td>
36-
</tr>
37-
</table>
38-
</div>
39-
40-
<div class="uploader-list" style="display:none;">
41-
<div class="uploader-item">
42-
... (generated thumbnails for each file)
43-
</div>
44-
</div>
45-
46-
<div class="file-edit-container" style="display:none;">
47-
... (elements for the edit UI)
48-
</div>
49-
50-
<script src="/resources/um/script/resumable.js"></script>
51-
<script src="/resources/um/script/resumable-uploader.js"></script>
52-
<script>
53-
uploader = (function($){
54-
var upload_token = '<api upload token>';
55-
var meta = {};
56-
return (new ResumableUploader(upload_token, meta, $('.resumable-browse'), $('.resumable-drop'), $('.progress'), $('.uploader-list'), $('.file-edit-container')));
57-
})(jQuery);
58-
</script>
59-
```
1+
# Flow.js front-end in jQuery
2+
Waiting for your contribution, for now look in Node.js sample at https://github.com/flowjs/flow.js/tree/master/samples/Node.js

samples/Node.js/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ File chunks will be uploaded to samples/Node.js/tmp directory.
1414

1515
## Enabling Cross-domain Uploads
1616

17-
If you would like to load the resumable.js library from one domain and have your Node.js reside on another, you must allow 'Access-Control-Allow-Origin' from '*'. Please remember, there are some potential security risks with enabling this functionality. If you would still like to implement cross-domain uploads, open app.js and uncomment lines 24-31 and uncomment line 17.
17+
If you would like to load the flow.js library from one domain and have your Node.js reside on another, you must allow 'Access-Control-Allow-Origin' from '*'. Please remember, there are some potential security risks with enabling this functionality. If you would still like to implement cross-domain uploads, open app.js and uncomment lines 24-31 and uncomment line 17.
1818

1919
Then in public/index.html, on line 49, update the target with your server's address. For example: target:'http://www.example.com/upload'

samples/Node.js/app.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var express = require('express');
2-
var resumable = require('./resumable-node.js')('tmp/');
2+
var flow = require('./flow-node.js')('tmp/');
33
var app = express();
44

55
// Host most stuff in the public folder
@@ -8,9 +8,9 @@ app.use(express.static(__dirname + '/../../src'));
88

99
app.use(express.bodyParser());
1010

11-
// Handle uploads through Resumable.js
11+
// Handle uploads through Flow.js
1212
app.post('/upload', function(req, res){
13-
resumable.post(req, function(status, filename, original_filename, identifier){
13+
flow.post(req, function(status, filename, original_filename, identifier){
1414
console.log('POST', status, original_filename, identifier);
1515
res.send(200, {
1616
// NOTE: Uncomment this funciton to enable cross-domain request.
@@ -30,16 +30,16 @@ app.post('/upload', function(req, res){
3030
});
3131
*/
3232

33-
// Handle status checks on chunks through Resumable.js
33+
// Handle status checks on chunks through Flow.js
3434
app.get('/upload', function(req, res){
35-
resumable.get(req, function(status, filename, original_filename, identifier){
35+
flow.get(req, function(status, filename, original_filename, identifier){
3636
console.log('GET', status);
3737
res.send(200, (status == 'found' ? 200 : 404));
3838
});
3939
});
4040

4141
app.get('/download/:identifier', function(req, res){
42-
resumable.write(req.params.identifier, res);
42+
flow.write(req.params.identifier, res);
4343
});
4444

4545
app.listen(3000);

samples/Node.js/resumable-node.js samples/Node.js/flow-node.js

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var fs = require('fs'), path = require('path'), util = require('util'), Stream =
22

33

44

5-
module.exports = resumable = function(temporaryFolder){
5+
module.exports = flow = function(temporaryFolder){
66
var $ = this;
77
$.temporaryFolder = temporaryFolder;
88
$.maxFileSize = null;
@@ -21,7 +21,7 @@ module.exports = resumable = function(temporaryFolder){
2121
// Clean up the identifier
2222
identifier = cleanIdentifier(identifier);
2323
// What would the file name be?
24-
return path.join($.temporaryFolder, './resumable-'+identifier+'.'+chunkNumber);
24+
return path.join($.temporaryFolder, './flow-'+identifier+'.'+chunkNumber);
2525
}
2626

2727
var validateRequest = function(chunkNumber, chunkSize, totalSize, identifier, filename, fileSize){
@@ -30,30 +30,30 @@ module.exports = resumable = function(temporaryFolder){
3030

3131
// Check if the request is sane
3232
if (chunkNumber==0 || chunkSize==0 || totalSize==0 || identifier.length==0 || filename.length==0) {
33-
return 'non_resumable_request';
33+
return 'non_flow_request';
3434
}
3535
var numberOfChunks = Math.max(Math.floor(totalSize/(chunkSize*1.0)), 1);
3636
if (chunkNumber>numberOfChunks) {
37-
return 'invalid_resumable_request1';
37+
return 'invalid_flow_request1';
3838
}
3939

4040
// Is the file too big?
4141
if($.maxFileSize && totalSize>$.maxFileSize) {
42-
return 'invalid_resumable_request2';
42+
return 'invalid_flow_request2';
4343
}
4444

4545
if(typeof(fileSize)!='undefined') {
4646
if(chunkNumber<numberOfChunks && fileSize!=chunkSize) {
4747
// The chunk in the POST request isn't the correct size
48-
return 'invalid_resumable_request3';
48+
return 'invalid_flow_request3';
4949
}
5050
if(numberOfChunks>1 && chunkNumber==numberOfChunks && fileSize!=((totalSize%chunkSize)+chunkSize)) {
5151
// The chunks in the POST is the last one, and the fil is not the correct size
52-
return 'invalid_resumable_request4';
52+
return 'invalid_flow_request4';
5353
}
5454
if(numberOfChunks==1 && fileSize!=totalSize) {
5555
// The file is only a single chunk, and the data size does not fit
56-
return 'invalid_resumable_request5';
56+
return 'invalid_flow_request5';
5757
}
5858
}
5959

@@ -63,11 +63,11 @@ module.exports = resumable = function(temporaryFolder){
6363
//'found', filename, original_filename, identifier
6464
//'not_found', null, null, null
6565
$.get = function(req, callback){
66-
var chunkNumber = req.param('resumableChunkNumber', 0);
67-
var chunkSize = req.param('resumableChunkSize', 0);
68-
var totalSize = req.param('resumableTotalSize', 0);
69-
var identifier = req.param('resumableIdentifier', "");
70-
var filename = req.param('resumableFilename', "");
66+
var chunkNumber = req.param('flowChunkNumber', 0);
67+
var chunkSize = req.param('flowChunkSize', 0);
68+
var totalSize = req.param('flowTotalSize', 0);
69+
var identifier = req.param('flowIdentifier', "");
70+
var filename = req.param('flowFilename', "");
7171

7272
if(validateRequest(chunkNumber, chunkSize, totalSize, identifier, filename)=='valid') {
7373
var chunkFilename = getChunkFilename(chunkNumber, identifier);
@@ -85,23 +85,23 @@ module.exports = resumable = function(temporaryFolder){
8585

8686
//'partly_done', filename, original_filename, identifier
8787
//'done', filename, original_filename, identifier
88-
//'invalid_resumable_request', null, null, null
89-
//'non_resumable_request', null, null, null
88+
//'invalid_flow_request', null, null, null
89+
//'non_flow_request', null, null, null
9090
$.post = function(req, callback){
9191

9292
var fields = req.body;
9393
var files = req.files;
9494

95-
var chunkNumber = fields['resumableChunkNumber'];
96-
var chunkSize = fields['resumableChunkSize'];
97-
var totalSize = fields['resumableTotalSize'];
98-
var identifier = cleanIdentifier(fields['resumableIdentifier']);
99-
var filename = fields['resumableFilename'];
95+
var chunkNumber = fields['flowChunkNumber'];
96+
var chunkSize = fields['flowChunkSize'];
97+
var totalSize = fields['flowTotalSize'];
98+
var identifier = cleanIdentifier(fields['flowIdentifier']);
99+
var filename = fields['flowFilename'];
100100

101-
var original_filename = fields['resumableIdentifier'];
101+
var original_filename = fields['flowIdentifier'];
102102

103103
if(!files[$.fileParameterName] || !files[$.fileParameterName].size) {
104-
callback('invalid_resumable_request', null, null, null);
104+
callback('invalid_flow_request', null, null, null);
105105
return;
106106
}
107107
var validation = validateRequest(chunkNumber, chunkSize, totalSize, identifier, files[$.fileParameterName].size);

0 commit comments

Comments
 (0)