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

[Do not merge] Idea: Support different client implementations #107

Open
wants to merge 3 commits 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
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

108 changes: 54 additions & 54 deletions .versions
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
[email protected].3
[email protected].1
[email protected].7
[email protected].7
[email protected].7
[email protected].6
[email protected].7
[email protected].7
[email protected].3
[email protected].7
check@1.1.3
[email protected].16
[email protected].4
[email protected].4
[email protected].4
[email protected].5
[email protected].11
[email protected].4
[email protected].2
[email protected].9
[email protected].10
[email protected].7
[email protected].8
[email protected].8
[email protected].4
[email protected].6
[email protected].7
local-test:vsivsi:[email protected].4
[email protected].11
[email protected].13
[email protected].13
modules@0.5.2
[email protected].2
[email protected].6
[email protected].3
[email protected].42
[email protected].10
[email protected].6
[email protected].6
[email protected].8
[email protected].8
[email protected].6
[email protected].9
[email protected].10
[email protected].10
[email protected].8
[email protected].9
[email protected].12
[email protected].10
[email protected].7
[email protected].8
vsivsi:file-collection@1.3.4
webapp@1.2.7
webapp-hashing@1.0.8
[email protected].4
[email protected].4
[email protected].8
[email protected].8
[email protected].8
[email protected].7
[email protected].8
[email protected].8
[email protected].4
[email protected].8
check@1.2.1
[email protected].17
[email protected].5
[email protected].7
[email protected].5
[email protected].6
[email protected].12
[email protected].5
[email protected].3
[email protected].10
[email protected].11
[email protected].8
[email protected].9
[email protected].9
[email protected].5
[email protected].7
[email protected].8
local-test:yciabaud:file-collection-server@1.3.4_5
[email protected].12
[email protected].14
[email protected].16
modules@0.6.1
[email protected].3
[email protected].7
[email protected].4
[email protected].43
[email protected].11
[email protected].7
[email protected].7
[email protected].9
[email protected].9
[email protected].7
[email protected].10
[email protected].11
[email protected].11
[email protected].9
[email protected].10
[email protected].13
[email protected].11
[email protected].8
[email protected].9
webapp@1.2.8
webapp-hashing@1.0.9
yciabaud:file-collection-server@1.3.4_5
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# file-collection

[![Build Status](https://travis-ci.org/vsivsi/meteor-file-collection.svg)](https://travis-ci.org/vsivsi/meteor-file-collection)
# file-collection-server

## Introduction

file-collection is a Meteor.js package that cleanly extends Meteor's Collection metaphor for efficiently dealing with collections of files and their data. File Collections are fully reactive, and if you know how to use Meteor Collections, you already know most of what you need to begin working with this package.
file-collection-server is an experimental fork of [file-collection](https://github.com/vsivsi/meteor-file-collection/) Meteor.js package that cleanly extends Meteor's Collection metaphor for efficiently dealing with collections of files and their data. File Collections are fully reactive, and if you know how to use Meteor Collections, you already know most of what you need to begin working with this package.

This fork removes the client part of the package to be able to work with different client implementations.

Major features:

* HTTP upload and download including support for Meteor authentication
* Client and Server integration of [resumable.js](http://resumablejs.com/) for robust chunked uploading
* Server integration of [resumable.js](http://resumablejs.com/) and [flow.js](https://github.com/flowjs/flow.js) for robust chunked uploading
* Also compatible with traditional HTTP POST or PUT file uploading
* HTTP range requests support random access for resumable downloads, media seeking, etc.
* Robust file locking allows safe replacement and removal of files even on a busy server
Expand Down
10 changes: 4 additions & 6 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
### See included LICENSE file for details.
***************************************************************************/

var currentVersion = '1.3.4';
var currentVersion = '1.3.4_5';

Package.describe({
summary: 'Collections that efficiently store files using MongoDB GridFS, with built-in HTTP support',
name: 'vsivsi:file-collection',
name: 'yciabaud:file-collection-server',
version: currentVersion,
git: 'https://github.com/vsivsi/meteor-file-collection.git'
git: 'https://github.com/yciabaud/meteor-file-collection.git'
});

Npm.depends({
Expand All @@ -31,19 +31,17 @@ Package.onUse(function(api) {
api.use('[email protected]', ['server', 'client']);
api.use('[email protected]', 'server');
api.use('[email protected]', ['server', 'client']);
api.addFiles('resumable/resumable.js', 'client');
api.addFiles('src/gridFS.coffee', ['server','client']);
api.addFiles('src/server_shared.coffee', 'server');
api.addFiles('src/gridFS_server.coffee', 'server');
api.addFiles('src/resumable_server.coffee', 'server');
api.addFiles('src/http_access_server.coffee', 'server');
api.addFiles('src/resumable_client.coffee', 'client');
api.addFiles('src/gridFS_client.coffee', 'client');
api.export('FileCollection');
});

Package.onTest(function (api) {
api.use('vsivsi:file-collection@' + currentVersion, ['server', 'client']);
api.use('yciabaud:file-collection-server@' + currentVersion, ['server', 'client']);
api.use('[email protected]', ['server', 'client']);
api.use('[email protected]', ['server', 'client']);
api.use('[email protected]', ['server','client']);
Expand Down
1 change: 0 additions & 1 deletion resumable
Submodule resumable deleted from f3085f
6 changes: 1 addition & 5 deletions src/gridFS_client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@ if Meteor.isClient

@base = @root
@baseURL = options.baseURL ? "/gridfs/#{@root}"
@resumableURL = "#{@baseURL}#{share.resumableBase}"
@chunkSize = options.chunkSize ? share.defaultChunkSize
super @root + '.files', { idGeneration: 'MONGO' }

# This call sets up the optional support for resumable.js
# See the resumable.coffee file for more information
if options.resumable
share.setup_resumable.bind(@)()

# remove works as-is. No modifications necessary so it currently goes straight to super

# Insert only creates an empty (but valid) gridFS file. To put data into it from a client,
Expand Down
52 changes: 0 additions & 52 deletions src/resumable_client.coffee

This file was deleted.

24 changes: 13 additions & 11 deletions src/resumable_server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,27 @@ if Meteor.isServer
lock.on 'timed-out', () -> callback new Meteor.Error "File Lock timed out"
lock.on 'error', (err) -> callback err

# Handle HTTP POST requests from Resumable.js
# Handle HTTP POST requests from Resumable.js or Flow.js

resumable_post_lookup = (params, query, multipart) ->
return { _id: share.safeObjectID(multipart?.params?.resumableIdentifier) }
return { _id: share.safeObjectID(multipart?.params?.resumableIdentifier || multipart?.params?.flowIdentifier) }

resumable_post_handler = (req, res, next) ->

# This has to be a resumable POST
unless req.multipart?.params?.resumableIdentifier
unless req.multipart?.params?.resumableIdentifier || req.multipart?.params?.flowIdentifier
console.error "Missing resumable.js multipart information"
res.writeHead(501, share.defaultResponseHeaders)
res.end()
return

resumable = req.multipart.params
resumable.resumableTotalSize = parseInt resumable.resumableTotalSize
resumable.resumableTotalChunks = parseInt resumable.resumableTotalChunks
resumable.resumableChunkNumber = parseInt resumable.resumableChunkNumber
resumable.resumableChunkSize = parseInt resumable.resumableChunkSize
resumable.resumableCurrentChunkSize = parseInt resumable.resumableCurrentChunkSize
resumable.resumableIdentifier = resumable.resumableIdentifier || resumable.flowIdentifier
resumable.resumableTotalSize = parseInt resumable.resumableTotalSize || resumable.flowTotalSize
resumable.resumableTotalChunks = parseInt resumable.resumableTotalChunks || resumable.flowTotalChunks
resumable.resumableChunkNumber = parseInt resumable.resumableChunkNumber || resumable.flowChunkNumber
resumable.resumableChunkSize = parseInt resumable.resumableChunkSize || resumable.flowChunkSize
resumable.resumableCurrentChunkSize = parseInt resumable.resumableCurrentChunkSize || resumable.flowCurrentChunkSize

if req.maxUploadSize > 0
unless resumable.resumableTotalSize <= req.maxUploadSize
Expand All @@ -161,6 +162,7 @@ if Meteor.isServer
((resumable.resumableChunkNumber is resumable.resumableTotalChunks) and
(resumable.resumableCurrentChunkSize < 2*resumable.resumableChunkSize)))

console.error("Error in POST params (%d)", req.gridFS.chunkSize, resumable)
res.writeHead(501, share.defaultResponseHeaders)
res.end()
return
Expand Down Expand Up @@ -214,7 +216,7 @@ if Meteor.isServer
res.end())

resumable_get_lookup = (params, query) ->
q = { _id: share.safeObjectID(query.resumableIdentifier) }
q = { _id: share.safeObjectID(query.resumableIdentifier || query.flowIdentifier) }
return q

# This handles Resumable.js "test GET" requests, that exist to determine
Expand All @@ -230,8 +232,8 @@ if Meteor.isServer
}
{
length: parseInt query.resumableCurrentChunkSize
'metadata._Resumable.resumableIdentifier': query.resumableIdentifier
'metadata._Resumable.resumableChunkNumber': parseInt query.resumableChunkNumber
'metadata._Resumable.resumableIdentifier': query.resumableIdentifier || query.flowIdentifier
'metadata._Resumable.resumableChunkNumber': parseInt query.resumableChunkNumber || query.flowChunkNumber
}
]

Expand Down