diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE index 1cfba129..5750af23 100644 --- a/.github/ISSUE_TEMPLATE +++ b/.github/ISSUE_TEMPLATE @@ -5,6 +5,11 @@ - Where this issue appears? OS (Mac/Win/Linux)? Browser name and its version? - Is it *Client* or *Server* issue? - Post *Client* and/or *Server* logs with enabled `debug` option, you can enable "debug" mode in [*Constructor*](https://github.com/VeliovGroup/Meteor-Files/wiki/Constructor) + +### I had an issue and I've solved it on my own: + - Provide a description of steps that you've followed to solve the problem. + - Provide links to websites and/or pages with the information that helped you (*if there are any*). + ### I have a suggestion: - Describe your feature / request diff --git a/.npm/package/npm-shrinkwrap.json b/.npm/package/npm-shrinkwrap.json index c4cfaa83..05588420 100644 --- a/.npm/package/npm-shrinkwrap.json +++ b/.npm/package/npm-shrinkwrap.json @@ -89,9 +89,9 @@ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=" }, "eventemitter3": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.0.0.tgz", - "integrity": "sha512-62TxCtz4m2LRaOERVEvLJJ4A6rsg8lC9Xm+FLg2y/1fB/v4ZZ9JCOn+/Ppl5KkH6sRih6bhix724PVanmXYZJQ==" + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.0.1.tgz", + "integrity": "sha512-QOCPu979MMWX9XNlfRZoin+Wm+bK1SP7vv3NGUniYwuSJK/+cPA10blMaeRgzg31RvoSFk6FsCDVa4vNryBTGA==" }, "extend": { "version": "3.0.1", @@ -114,9 +114,9 @@ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, "file-type": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-7.4.0.tgz", - "integrity": "sha1-KnyU9ioAMBULt9m2xwz6HT51nIY=" + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-7.5.0.tgz", + "integrity": "sha512-siGSLPCL9mJM10TaTswSF2Ry60stJaemPbAf2StSGOcjlfVIA2V/wX3Qg8IiTHmGLMch0ZaM9DhszSo5rfIulg==" }, "forever-agent": { "version": "0.6.1", @@ -284,9 +284,9 @@ "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=" }, "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" }, "verror": { "version": "1.10.0", diff --git a/.versions b/.versions index 0eafdc4b..7fad82eb 100644 --- a/.versions +++ b/.versions @@ -1,43 +1,46 @@ allow-deny@1.1.0 -babel-compiler@6.24.7 -babel-runtime@1.1.1 +babel-compiler@7.0.3 +babel-runtime@1.2.0 base64@1.0.10 binary-heap@1.0.10 -boilerplate-generator@1.3.0 -callback-hook@1.0.10 -check@1.2.5 +boilerplate-generator@1.4.0 +callback-hook@1.1.0 +check@1.3.0 ddp@1.4.0 -ddp-client@2.2.0 -ddp-common@1.3.0 -ddp-server@2.1.0 -diff-sequence@1.0.7 -ecmascript@0.9.0 +ddp-client@2.3.1 +ddp-common@1.4.0 +ddp-server@2.1.2 +diff-sequence@1.1.0 +dynamic-import@0.3.0 +ecmascript@0.10.0 ecmascript-runtime@0.5.0 -ecmascript-runtime-client@0.5.0 +ecmascript-runtime-client@0.6.0 ecmascript-runtime-server@0.5.0 ejson@1.1.0 geojson-utils@1.0.10 -http@1.3.0 -id-map@1.0.9 +http@1.4.0 +id-map@1.1.0 logging@1.1.19 -meteor@1.8.0 -minimongo@1.4.0 -modules@0.11.0 -modules-runtime@0.9.0 -mongo@1.3.1 +meteor@1.8.2 +minimongo@1.4.3 +modules@0.11.3 +modules-runtime@0.9.1 +mongo@1.4.2 mongo-dev-server@1.1.0 mongo-id@1.0.6 npm-mongo@2.2.33 -ordered-dict@1.0.9 +ordered-dict@1.1.0 ostrio:cookies@2.2.4 -ostrio:files@1.9.6 -promise@0.10.0 -random@1.0.10 +ostrio:files@1.9.7 +promise@0.10.1 +random@1.1.0 reactive-var@1.0.11 -retry@1.0.9 +reload@1.2.0 +retry@1.1.0 routepolicy@1.0.12 +socket-stream-client@0.1.0 tracker@1.1.3 underscore@1.0.10 -url@1.1.0 -webapp@1.4.0 +url@1.2.0 +webapp@1.5.0 webapp-hashing@1.0.9 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db8f5915..98c7febe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ 1. Search [issues](https://github.com/VeliovGroup/Meteor-Files/issues), maybe your issue is already solved 2. We have useful threads makred as [`In a case of the fire - Read This`](https://github.com/VeliovGroup/Meteor-Files/issues?utf8=✓&q=label%3A%22In%20a%20case%20of%20the%20fire%20-%20Read%20This%22), read them too 3. Before submitting an issue make sure it's only related to `Meteor-Files` package - 4. If your issue not solved: + 4. If your issue is not solved: - Give an expressive description of what is went wrong - Version of `Meteor-Files` you're experiencing this issue - Version of `Meteor` you're experiencing this issue @@ -10,19 +10,19 @@ - Post *Client* and/or *Server* logs with enabled `debug` option, you can enable "debug" mode in [*Constructor*](https://github.com/VeliovGroup/Meteor-Files/wiki/Constructor) ### I have a suggestion: - 1. PRs is always welcome - [send a PR](https://github.com/VeliovGroup/Meteor-Files/compare) + 1. PRs are always welcome - [send a PR](https://github.com/VeliovGroup/Meteor-Files/compare) - Always send PRs only to [`dev` branch](https://github.com/VeliovGroup/Meteor-Files/compare/dev), thank you - 2. If you you can not send a PR for some reason: + 2. If you're can not send a PR for some reason: - Create a new issue ticket - Describe your feature / request - How you going to use it? Give a usage example(s) ### Documentation is missing something or incorrect (have typos, etc.): - 1. PRs is always welcome - [send a PR](https://github.com/VeliovGroup/Meteor-Files/compare) + 1. PRs are always welcome - [send a PR](https://github.com/VeliovGroup/Meteor-Files/compare) - Always send PRs only to [`dev` branch](https://github.com/VeliovGroup/Meteor-Files/compare/dev), thank you - 2. If you you can not send a PR for some reason: + 2. If you're can not send a PR to docs for some reason: - Create a new issue ticket - Give an expressive description what you have changed/added and why - Make sure you're using correct markdown markup - - Make sure all code blocks starts with tripple ``` (*backtick*) and have a syntax tag, for more read [this docs](https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting) - - Post your addition/changes as issue ticket, we will manage it \ No newline at end of file + - Make sure all code blocks starts with triple ``` (*backtick*) and have a syntax tag, for more read [this docs](https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting) + - Post addition/changes as issue ticket, we will manage it \ No newline at end of file diff --git a/LICENSE b/LICENSE index 4a572a56..7690d35d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2017, Dmitriy A. (Veliov Group, LLC) +Copyright (c) 2018, dr.dimitru (Dmitriy A.; Veliov Group, LLC) All rights reserved. Redistribution and use in source and binary forms, diff --git a/README.md b/README.md index d29de8e1..b640b9bf 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Support Meteor-Files project: Contribution: ======== -All PRs is always welcome on [`dev` branch](https://github.com/VeliovGroup/Meteor-Files/tree/dev). Please, always give expressive description to your changes and additions. +All PRs are always welcome on [`dev` branch](https://github.com/VeliovGroup/Meteor-Files/tree/dev). Please, always give expressive description to your changes and additions. Awards: ======== diff --git a/client.js b/client.js index 617c0bdf..c8c69469 100644 --- a/client.js +++ b/client.js @@ -80,7 +80,7 @@ export class FilesCollection extends FilesCollectionCore { check(this.collectionName, String); if (this.public && !this.downloadRoute) { - throw new Meteor.Error(500, `[FilesCollection.${this.collectionName}]: \"downloadRoute\" must be precisely provided on \"public\" collections! Note: \"downloadRoute\" must be equal or be inside of your web/proxy-server (relative) root.`); + throw new Meteor.Error(500, `[FilesCollection.${this.collectionName}]: "downloadRoute" must be precisely provided on "public" collections! Note: "downloadRoute" must be equal or be inside of your web/proxy-server (relative) root.`); } if (!_.isBoolean(this.disableUpload)) { @@ -231,6 +231,7 @@ export class FilesCollection extends FilesCollectionCore { * @see https://developer.mozilla.org/en-US/docs/Web/API/FileReader * @param {Object} config - Configuration object with next properties: * {File|Object} file - HTML5 `files` item, like in change event: `e.currentTarget.files[0]` + * {String} fileId - Optionnal `fileId` used at insert * {Object} meta - Additional data as object, use later for search * {Boolean} allowWebWorkers- Allow/Deny WebWorkers usage * {Number|dynamic} streams - Quantity of parallel upload streams, default: 2 diff --git a/docs/insert.md b/docs/insert.md index 0e5798b1..35e555d9 100644 --- a/docs/insert.md +++ b/docs/insert.md @@ -40,6 +40,17 @@ Set to dataURI {String} for Base64 + + + settings.fileId {String} + + + Explicitly set the fileId for the file + + + This is an optionnal parameters Random.id() will be used otherwise + + settings.fileName {String} diff --git a/package.js b/package.js index aaeb151d..ad41b30f 100755 --- a/package.js +++ b/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'ostrio:files', - version: '1.9.6', + version: '1.9.7', summary: 'File upload via DDP/HTTP to server, 3rd party storage support: AWS S3, GridFS, DropBox and others', git: 'https://github.com/VeliovGroup/Meteor-Files', documentation: 'README.md' @@ -9,8 +9,8 @@ Package.describe({ Npm.depends({ 'fs-extra': '5.0.0', 'request': '2.83.0', - 'file-type': '7.4.0', - 'eventemitter3': '3.0.0' + 'file-type': '7.5.0', + 'eventemitter3': '3.0.1' }); Package.onUse(function(api) { diff --git a/server.js b/server.js index 2bc239ed..01a3645f 100644 --- a/server.js +++ b/server.js @@ -133,7 +133,7 @@ export class FilesCollection extends FilesCollectionCore { check(this.collectionName, String); if (this.public && !this.downloadRoute) { - throw new Meteor.Error(500, `[FilesCollection.${this.collectionName}]: \"downloadRoute\" must be precisely provided on \"public\" collections! Note: \"downloadRoute\" must be equal or be inside of your web/proxy-server (relative) root.`); + throw new Meteor.Error(500, `[FilesCollection.${this.collectionName}]: "downloadRoute" must be precisely provided on "public" collections! Note: "downloadRoute" must be equal or be inside of your web/proxy-server (relative) root.`); } if (!_.isString(this.downloadRoute)) { @@ -242,7 +242,7 @@ export class FilesCollection extends FilesCollectionCore { } if (this.public && !storagePath) { - throw new Meteor.Error(500, `[FilesCollection.${this.collectionName}] \"storagePath\" must be set on \"public\" collections! Note: \"storagePath\" must be equal on be inside of your web/proxy-server (absolute) root.`); + throw new Meteor.Error(500, `[FilesCollection.${this.collectionName}] "storagePath" must be set on "public" collections! Note: "storagePath" must be equal on be inside of your web/proxy-server (absolute) root.`); } if (!storagePath) { @@ -257,7 +257,7 @@ export class FilesCollection extends FilesCollectionCore { this.storagePath = function () { let sp = storagePath.apply(self, arguments); if (!_.isString(sp)) { - throw new Meteor.Error(400, `[FilesCollection.${self.collectionName}] \"storagePath\" function must return a String!`); + throw new Meteor.Error(400, `[FilesCollection.${self.collectionName}] "storagePath" function must return a String!`); } sp = sp.replace(/\/$/, ''); return nodePath.normalize(sp); @@ -268,7 +268,7 @@ export class FilesCollection extends FilesCollectionCore { fs.mkdirs(this.storagePath({}), { mode: this.parentDirPermissions }, (error) => { if (error) { - throw new Meteor.Error(401, `[FilesCollection.${self.collectionName}] Path \"${this.storagePath({})}\" is not writable!`, error); + throw new Meteor.Error(401, `[FilesCollection.${self.collectionName}] Path "${this.storagePath({})}" is not writable! ${error}`); } }); diff --git a/upload.js b/upload.js index be4e7645..53a78f65 100644 --- a/upload.js +++ b/upload.js @@ -60,6 +60,7 @@ export class UploadInstance extends EventEmitter { check(this.config, { ddp: Match.Any, file: Match.Any, + fileId: Match.Optional(String), meta: Match.Optional(Object), type: Match.Optional(String), onError: Match.Optional(Function), @@ -151,7 +152,7 @@ export class UploadInstance extends EventEmitter { this.sentChunks = 0; this.fileLength = 1; this.EOFsent = false; - this.fileId = Random.id(); + this.fileId = this.config.fileId || Random.id(); this.FSName = this.collection.namingFunction ? this.collection.namingFunction(this.fileData) : this.fileId; this.pipes = []; diff --git a/write-stream.js b/write-stream.js index aea0055a..d5396f14 100644 --- a/write-stream.js +++ b/write-stream.js @@ -41,12 +41,14 @@ export default class WriteStream { fs.ensureFile(this.path, (efError) => { bound(() => { if (efError) { - throw new Meteor.Error(500, '[FilesCollection] [writeStream] [ensureFile] [Error:]', efError); + this.abort(); + throw new Meteor.Error(500, '[FilesCollection] [writeStream] [ensureFile] [Error:] ' + efError); } else { fs.open(this.path, 'r+', this.permissions, (oError, fd) => { bound(() => { if (oError) { - throw new Meteor.Error(500, '[FilesCollection] [writeStream] [ensureFile] [open] [Error:]', oError); + this.abort(); + throw new Meteor.Error(500, '[FilesCollection] [writeStream] [ensureFile] [open] [Error:] ' + oError); } else { this.fd = fd; fdCache[this.path] = this;