diff --git a/.npm/package/npm-shrinkwrap.json b/.npm/package/npm-shrinkwrap.json index 0935522b..894d3020 100644 --- a/.npm/package/npm-shrinkwrap.json +++ b/.npm/package/npm-shrinkwrap.json @@ -58,7 +58,7 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "from": "core-util-is@>=1.0.0 <1.1.0" + "from": "core-util-is@1.0.2" }, "cryptiles": { "version": "2.0.5", @@ -98,14 +98,14 @@ "from": "extend@>=3.0.0 <3.1.0" }, "extsprintf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", - "from": "extsprintf@1.0.2" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "from": "extsprintf@1.3.0" }, "file-type": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", - "from": "file-type@5.2.0" + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.1.0.tgz", + "from": "file-type@6.1.0" }, "forever-agent": { "version": "0.6.1", @@ -118,9 +118,9 @@ "from": "form-data@>=2.1.1 <2.2.0" }, "fs-extra": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.0.tgz", - "from": "fs-extra@4.0.0" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.1.tgz", + "from": "fs-extra@4.0.1" }, "getpass": { "version": "0.1.7", @@ -215,8 +215,8 @@ "from": "jsonify@>=0.0.0 <0.1.0" }, "jsprim": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", "from": "jsprim@>=1.2.2 <2.0.0", "dependencies": { "assert-plus": { @@ -227,13 +227,13 @@ } }, "mime-db": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", - "from": "mime-db@>=1.27.0 <1.28.0" + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "from": "mime-db@>=1.30.0 <1.31.0" }, "mime-types": { - "version": "2.1.15", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", "from": "mime-types@>=2.1.7 <2.2.0" }, "ms": { @@ -349,9 +349,16 @@ "from": "uuid@>=3.0.0 <4.0.0" }, "verror": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", - "from": "verror@1.3.6" + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "from": "verror@1.10.0", + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "from": "assert-plus@>=1.0.0 <2.0.0" + } + } } } } diff --git a/.versions b/.versions index 9f2ba9c3..472e513e 100644 --- a/.versions +++ b/.versions @@ -1,54 +1,45 @@ allow-deny@1.0.6 -babel-compiler@6.19.4 +babel-compiler@6.20.0 babel-runtime@1.0.1 base64@1.0.10 binary-heap@1.0.10 -blaze@2.3.2 -blaze-tools@1.0.10 -boilerplate-generator@1.1.1 +boilerplate-generator@1.2.0 caching-compiler@1.1.9 callback-hook@1.0.10 check@1.2.5 coffeescript@1.11.1_3 ddp@1.3.0 -ddp-client@2.0.0 +ddp-client@2.1.0 ddp-common@1.2.9 ddp-server@2.0.0 -deps@1.0.12 diff-sequence@1.0.7 -ecmascript@0.8.1 +ecmascript@0.8.2 ecmascript-runtime@0.4.1 -ecmascript-runtime-client@0.4.2 +ecmascript-runtime-client@0.4.3 ecmascript-runtime-server@0.4.1 -ejson@1.0.13 +ejson@1.0.14 geojson-utils@1.0.10 -html-tools@1.0.11 -htmljs@1.0.11 http@1.2.12 id-map@1.0.9 -jquery@1.11.10 logging@1.1.17 -meteor@1.7.0 -minimongo@1.2.1 -modules@0.9.2 +meteor@1.7.1 +minimongo@1.3.0 +modules@0.10.0 modules-runtime@0.8.0 -mongo@1.1.19 +mongo@1.2.0 +mongo-dev-server@1.0.1 mongo-id@1.0.6 -npm-mongo@2.2.24 -observe-sequence@1.0.16 +npm-mongo@2.2.30 ordered-dict@1.0.9 ostrio:cookies@2.2.2 -ostrio:files@1.8.2 -promise@0.8.9 +ostrio:files@1.8.3 +promise@0.9.0 random@1.0.10 reactive-var@1.0.11 retry@1.0.9 routepolicy@1.0.12 -spacebars@1.0.15 -spacebars-compiler@1.1.2 tracker@1.1.3 -ui@1.0.13 underscore@1.0.10 url@1.1.0 -webapp@1.3.17 +webapp@1.3.18 webapp-hashing@1.0.9 diff --git a/client.coffee b/client.coffee index 28e3fe19..e95fbad1 100755 --- a/client.coffee +++ b/client.coffee @@ -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 diff --git a/cursor.coffee b/cursor.coffee index 68ce7090..d66253c2 100644 --- a/cursor.coffee +++ b/cursor.coffee @@ -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 '' diff --git a/docs/collection-instances.md b/docs/collection-instances.md index 4c446865..5f04eb35 100644 --- a/docs/collection-instances.md +++ b/docs/collection-instances.md @@ -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; ```` \ No newline at end of file diff --git a/docs/collection.md b/docs/collection.md index ab0d356d..c22494b2 100644 --- a/docs/collection.md +++ b/docs/collection.md @@ -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 } }); }); diff --git a/docs/constructor.md b/docs/constructor.md index 07d5beb4..0f357a94 100644 --- a/docs/constructor.md +++ b/docs/constructor.md @@ -102,7 +102,7 @@ - config.continueUploadTTL {String} + config.continueUploadTTL {Number} Server @@ -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); diff --git a/docs/file-subversions.md b/docs/file-subversions.md index 69c188a8..661738c2 100644 --- a/docs/file-subversions.md +++ b/docs/file-subversions.md @@ -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); diff --git a/docs/image-processing.md b/docs/image-processing.md index 1f2e8fcc..ed0d4ca6 100644 --- a/docs/image-processing.md +++ b/docs/image-processing.md @@ -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 diff --git a/lib.coffee b/lib.coffee index d872f6e7..f79613c2 100644 --- a/lib.coffee +++ b/lib.coffee @@ -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 = '' diff --git a/package.js b/package.js index 4600f6b3..ca4c7ad9 100755 --- a/package.js +++ b/package.js @@ -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) { diff --git a/server.coffee b/server.coffee index c0b85885..3acd7974 100644 --- a/server.coffee +++ b/server.coffee @@ -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'` @@ -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 @@ -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 @@ -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