Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"mime": "1.3.4",
"mongodb": "2.2.9",
"multer": "1.2.0",
"node-uuid": "^1.4.7",
"parse": "1.9.1",
"parse-server-fs-adapter": "1.0.1",
"parse-server-push-adapter": "1.1.0",
Expand Down
7 changes: 2 additions & 5 deletions src/Controllers/FilesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AdaptableController from './AdaptableController';
import { FilesAdapter } from '../Adapters/Files/FilesAdapter';
import path from 'path';
import mime from 'mime';
import uuid from 'node-uuid';

const legacyFilesRegex = new RegExp("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}-.*");

Expand All @@ -26,11 +27,7 @@ export class FilesController extends AdaptableController {
contentType = mime.lookup(filename);
}

// increased the random string length to 36 so that it is the same length as an UUID with dashes.
// This makes file name property extraction for display in clients such as Parse Dashboard to work correctly.
// We can not use an UUID with dashes here because it is already used for files.parse.com hosted files and
// expandFilesInObject method below uses this distinction to construct the correct url for the file.
filename = randomHexString(36) + '_' + filename;
filename = uuid.v4() + '_' + filename;

var location = this.adapter.getFileLocation(config, filename);
return this.adapter.createFile(filename, data, contentType).then(() => {
Expand Down