Skip to content

Commit

Permalink
Merge pull request #490 from VeliovGroup/dev
Browse files Browse the repository at this point in the history
v1.8.3
  • Loading branch information
dr-dimitru committed Sep 10, 2017
2 parents c800703 + a1a58a9 commit 1d1be8a
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 62 deletions.
47 changes: 27 additions & 20 deletions .npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 15 additions & 24 deletions .versions
4 changes: 2 additions & 2 deletions client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ class FilesCollection

try
_URL = window.URL || window.webkitURL || window.mozURL || window.msURL || window.oURL || false
if window?.Worker and window?.Blob and _URL
if window.Worker and window.Blob and _URL
@_supportWebWorker = true
@_webWorkerUrl = _URL.createObjectURL(new Blob(['!function(a){"use strict";a.onmessage=function(b){var c=b.data.f.slice(b.data.cs*(b.data.cc-1),b.data.cs*b.data.cc);if(b.data.ib===!0)postMessage({bin:c,chunkId:b.data.cc});else{var d;a.FileReader?(d=new FileReader,d.onloadend=function(a){postMessage({bin:(d.result||a.srcElement||a.target).split(",")[1],chunkId:b.data.cc,s:b.data.s})},d.onerror=function(a){throw(a.target||a.srcElement).error},d.readAsDataURL(c)):a.FileReaderSync?(d=new FileReaderSync,postMessage({bin:d.readAsDataURL(c).split(",")[1],chunkId:b.data.cc})):postMessage({bin:null,chunkId:b.data.cc,error:"File API is not supported in WebWorker!"})}}}(this);'], {type: 'application/javascript'}))
else if window?.Worker
else if window.Worker
@_supportWebWorker = true
@_webWorkerUrl = Meteor.absoluteUrl 'packages/ostrio_files/worker.min.js'
else
Expand Down
2 changes: 1 addition & 1 deletion cursor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FileCursor
@summary Returns downloadable URL to File
@returns {String}
###
link: (version) ->
link: (version = 'original') ->
@_collection._debug "[FilesCollection] [FileCursor] [link(#{version})]"
return if @_fileRef then @_collection.link(@_fileRef, version) else ''

Expand Down
6 changes: 3 additions & 3 deletions docs/collection-instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ This simplified example shows, how to make use of that technique in your own imp
Assume having a map of all `Mongo.Collection` instances:
```javascript
constvar collectionsMap = {};
const collectionsMap = {};
````

Since you may not want to store the *FilesCollection* instance (*because it is not a* `Mongo.Collection`), you can still reference the underlying Mongo.Collection:

```javascript
var Images = new FilesCollection({collectionName: 'Images'});
const Images = new FilesCollection({collectionName: 'Images'});
collectionsMap['Images'] = Images.collection;
````
Access the *FilesCollection* by reference:
```javascript
var Images = collectionsMap['Images'].filesCollection;
const Images = collectionsMap['Images'].filesCollection;
````
3 changes: 2 additions & 1 deletion docs/collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ if (Meteor.isServer) {
fields: {
extension: 1,
_downloadRoute: 1,
_collectionName: 1
_collectionName: 1,
'versions.versionName.extension': 1 // <-- Required only for file's version .link(version), and if extension is different from original file
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions docs/constructor.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
</tr>
<tr>
<td align="right">
<code>config.continueUploadTTL</code> {<em>String</em>}
<code>config.continueUploadTTL</code> {<em>Number</em>}
</td>
<td>
Server
Expand Down Expand Up @@ -907,7 +907,7 @@ const Images = new FilesCollection({
// check real mimetype
const { Magic, MAGIC_MIME_TYPE } = require('mmmagic');
const magic = new Magic(MAGIC_MIME_TYPE);
magic.detectFile(file.path, Meteor.bindEnvironment((err, mimetype) => {
magic.detectFile(file.path, Meteor.bindEnvironment((err, mimeType) => {
if (err || !~mimeType.indexOf('image')) {
// is not a real image --> delete
console.log('onAfterUpload, not an image: ', file.path);
Expand Down
1 change: 1 addition & 0 deletions docs/file-subversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ this.Videos = new FilesCollection({
path: version.path,
size: version.size,
type: version.type,
name: version.nameWithExtension,
extension: version.extension
};
return Videos.update(fileRef._id, upd);
Expand Down
1 change: 1 addition & 0 deletions docs/image-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ const createThumbnails = (collection, fileRef, cb) => {
size: stat.size,
type: fileRef.type,
extension: fileRef.extension,
name: fileRef.name, // <-- Name with extension used if file's version is being downloaded
meta: {
width: imgInfo.width,
height: imgInfo.height
Expand Down
5 changes: 3 additions & 2 deletions lib.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ formatFleURL = (fileRef, version = 'original') ->
check version, String

root = __meteor_runtime_config__.ROOT_URL.replace(/\/+$/, '')
vRef = ((fileRef.versions and fileRef.versions[version]) or fileRef)

if fileRef.extension?.length
ext = '.' + fileRef.extension
if vRef.extension?.length
ext = '.' + vRef.extension.replace(/^\./, '')
else
ext = ''

Expand Down
6 changes: 3 additions & 3 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Package.describe({
name: 'ostrio:files',
version: '1.8.2',
version: '1.8.3',
summary: 'File upload via DDP/HTTP to server FS, AWS, GridFS, DropBox, Google Drive or other 3rd party storage',
git: 'https://github.com/VeliovGroup/Meteor-Files',
documentation: 'README.md'
});

Npm.depends({
'fs-extra': '4.0.0',
'fs-extra': '4.0.1',
'request': '2.81.0',
'throttle': '1.0.3',
'file-type': '5.2.0'
'file-type': '6.1.0'
});

Package.onUse(function(api) {
Expand Down
9 changes: 5 additions & 4 deletions server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@summary Require NPM packages
###
`import fs from 'fs-extra'`
`import nodeQs from 'querystring'`
`import events from 'events'`
`import request from 'request'`
`import Throttle from 'throttle'`
Expand Down Expand Up @@ -400,10 +401,10 @@ class FilesCollection
uris = uri.split '/'
if uris.length is 3
params =
query: if request._parsedUrl.query then JSON.parse('{"' + decodeURI(request._parsedUrl.query).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}') else {}
query: if request._parsedUrl.query then nodeQs.parse(request._parsedUrl.query) else {}
_id: uris[0]
version: uris[1]
name: uris[2]
name: uris[2].split('?')[0]
http = {request, response, params}
self.download http, uris[1], self.collection.findOne(uris[0]) if self._checkAccess http
else
Expand All @@ -427,7 +428,7 @@ class FilesCollection
_file = _file.split('?')[0]

params =
query: if request._parsedUrl.query then JSON.parse('{"' + decodeURI(request._parsedUrl.query).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}') else {}
query: if request._parsedUrl.query then nodeQs.parse(request._parsedUrl.query) else {}
file: _file
_id: _file.split('.')[0]
version: version
Expand Down Expand Up @@ -1184,7 +1185,7 @@ class FilesCollection
else
dispositionType = 'inline; '

dispositionName = "filename=\"#{encodeURI(fileRef.name)}\"; filename*=UTF-8''#{encodeURI(fileRef.name)}; "
dispositionName = "filename=\"#{encodeURI(vRef.name or fileRef.name)}\"; filename*=UTF-8''#{encodeURI(vRef.name or fileRef.name)}; "
dispositionEncoding = 'charset=UTF-8'

if !http.response.headersSent
Expand Down

0 comments on commit 1d1be8a

Please sign in to comment.