Skip to content

Commit

Permalink
Merge pull request #583 from VeliovGroup/dev
Browse files Browse the repository at this point in the history
v1.9.8
 - Fix: #579 , thanks to @coagmano
 - Fix: #581 , thanks to @sleepoiKot
 - Fix: #547 , thanks to @hacknlove
 - NPM & Atmosphere dependencies update
 - Overall minor fixes & codebase enhancements
 - Minimal required Meteor's version is raised up to `v1.6.1` (via `api.versionsFrom`)
  • Loading branch information
dr-dimitru authored Feb 26, 2018
2 parents f08f897 + a6a239c commit b898d4e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
PRs ONLY ACCEPTED TO `dev` BRANCH! MAKE SURE YOU'RE SENDING A PR TO `dev` BRANCH!

Thank you for contribution. Before you go:
1. Make sure you're using `spaces` for indentation
2. Make sure all new code is documented in-code-docs
Expand Down
36 changes: 18 additions & 18 deletions .npm/package/npm-shrinkwrap.json

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

2 changes: 1 addition & 1 deletion .versions
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ [email protected]
[email protected]
[email protected]
ostrio:[email protected]
ostrio:[email protected].7
ostrio:[email protected].8
[email protected]
[email protected]
[email protected]
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### I'm having an issue:
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
2. We have useful threads marked 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 is not solved:
- Give an expressive description of what is went wrong
Expand Down
8 changes: 7 additions & 1 deletion core.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export default class FilesCollectionCore extends EventEmitter {
},
mime: {
type: String,
optional: true
},
'mime-type': {
type: String,
optional: true
},
_storagePath: {
type: String
Expand Down Expand Up @@ -117,7 +119,7 @@ export default class FilesCollectionCore extends EventEmitter {
_getFileName(fileData) {
const fileName = fileData.name || fileData.fileName;
if (_.isString(fileName) && (fileName.length > 0)) {
return (fileData.name || fileData.fileName).replace(/\.\./g, '').replace(/\//g, '');
return (fileData.name || fileData.fileName).replace(/^\.\.+/, '').replace(/\.{2,}/g, '.').replace(/\//g, '');
}
return '';
}
Expand Down Expand Up @@ -166,9 +168,13 @@ export default class FilesCollectionCore extends EventEmitter {
const ds = {
name: data.name,
extension: data.extension,
ext: data.extension,
extensionWithDot: '.' + data.extension,
path: data.path,
meta: data.meta,
type: data.type,
mime: data.type,
'mime-type': data.type,
size: data.size,
userId: data.userId || null,
versions: {
Expand Down
2 changes: 2 additions & 0 deletions docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ var defaultSchema = {
},
mime: {
type: String,
optional: true
},
'mime-type': {
type: String,
optional: true
},
_storagePath: {
type: String
Expand Down
6 changes: 3 additions & 3 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'ostrio:files',
version: '1.9.7',
version: '1.9.8',
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'
Expand All @@ -9,12 +9,12 @@ Package.describe({
Npm.depends({
'fs-extra': '5.0.0',
'request': '2.83.0',
'file-type': '7.5.0',
'file-type': '7.6.0',
'eventemitter3': '3.0.1'
});

Package.onUse(function(api) {
api.versionsFrom('1.4');
api.versionsFrom('1.6.1');
api.use('webapp', 'server');
api.use(['reactive-var', 'tracker', 'http'], 'client');
api.use(['mongo', 'underscore', 'check', 'random', 'ecmascript', 'ostrio:[email protected]'], ['client', 'server']);
Expand Down
15 changes: 8 additions & 7 deletions upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { EventEmitter } from 'eventemitter3';
import { check, Match } from 'meteor/check';
import { fixJSONParse, fixJSONStringify } from './lib.js';

const _rootUrl = (window.__meteor_runtime_config__.MOBILE_ROOT_URL || window.__meteor_runtime_config__.ROOT_URL).replace(/\/+$/, '');
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

/*
Expand Down Expand Up @@ -297,7 +298,7 @@ export class UploadInstance extends EventEmitter {
}
});
} else {
HTTP.call('POST', `${this.collection.downloadRoute}/${this.collection.collectionName}/__upload`, {
HTTP.call('POST', `${_rootUrl}${this.collection.downloadRoute}/${this.collection.collectionName}/__upload`, {
content: opts.binData,
headers: {
'x-mtok': (_.isObject(Meteor.connection) ? Meteor.connection._lastSessionId : undefined) || null,
Expand Down Expand Up @@ -343,7 +344,7 @@ export class UploadInstance extends EventEmitter {
this.emit('end', error, result);
});
} else {
HTTP.call('POST', `${this.collection.downloadRoute}/${this.collection.collectionName}/__upload`, {
HTTP.call('POST', `${_rootUrl}${this.collection.downloadRoute}/${this.collection.collectionName}/__upload`, {
content: '',
headers: {
'x-eof': '1',
Expand Down Expand Up @@ -382,8 +383,8 @@ export class UploadInstance extends EventEmitter {
});
} else {
let fileReader;
if (FileReader) {
fileReader = new FileReader;
if (window.FileReader) {
fileReader = new window.FileReader;

fileReader.onloadend = (evt) => {
this.emit('sendChunk', {
Expand All @@ -399,8 +400,8 @@ export class UploadInstance extends EventEmitter {
};

fileReader.readAsDataURL(chunk);
} else if (FileReaderSync) {
fileReader = new FileReaderSync;
} else if (window.FileReaderSync) {
fileReader = new window.FileReaderSync;

this.emit('sendChunk', {
data: {
Expand Down Expand Up @@ -529,7 +530,7 @@ export class UploadInstance extends EventEmitter {
opts.file.meta = fixJSONStringify(opts.file.meta);
}

HTTP.call('POST', `${this.collection.downloadRoute}/${this.collection.collectionName}/__upload`, {
HTTP.call('POST', `${_rootUrl}${this.collection.downloadRoute}/${this.collection.collectionName}/__upload`, {
data: opts,
headers: {
'x-start': '1',
Expand Down

0 comments on commit b898d4e

Please sign in to comment.