File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ $ npm start config.js
5959* ` masterKey ` : Parse master key.
6060* ` serverURL ` : The URL for the Parse server (default: http://api.parse.com/1 ).
6161This is used to with ` applicationId ` and ` masterKey ` to get the schema and fetch all files/objects.
62+ * ` renameFiles ` (boolean): Whether or not to rename Parse hosted files.
63+ This removes the "tfss-" or legacy Parse filename prefix before saving with the new file adapter.
6264* ` renameInDatabase ` (boolean): Whether or not to rename files in MongoDB.
6365* ` mongoURL ` : MongoDB connection url.
6466Direct access to the database is needed because Parse SDK doesn't allow direct writing to file fields.
Original file line number Diff line number Diff line change @@ -34,13 +34,24 @@ function questions(config) {
3434 { name : 'All files' , value : 'all' }
3535 ] ,
3636 when : ( [ 'parseOnly' , 'parseServerOnly' , 'all' ] . indexOf ( config . filesToTransfer ) == - 1 )
37+ } , {
38+ type : 'confirm' ,
39+ name : 'renameFiles' ,
40+ message : 'Rename Parse hosted file names?' ,
41+ default : false ,
42+ when : function ( answers ) {
43+ return config . renameFiles == undefined &&
44+ ( answers . filesToTransfer == 'all' || config . filesToTransfer == 'all' ||
45+ config . filesToTransfer == 'parseOnly' || answers . filesToTransfer == 'parseOnly' ) ;
46+ }
3747 } , {
3848 type : 'confirm' ,
3949 name : 'renameInDatabase' ,
4050 message : 'Rename Parse hosted files in the database after transfer?' ,
4151 default : false ,
4252 when : function ( answers ) {
43- return ! config . renameInDatabase &&
53+ return config . renameInDatabase == undefined &&
54+ ( answers . renameFiles || config . renameFiles ) &&
4455 ( answers . filesToTransfer == 'all' || config . filesToTransfer == 'all' ||
4556 config . filesToTransfer == 'parseOnly' || answers . filesToTransfer == 'parseOnly' ) ;
4657 }
Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ function _requestErrorHandler(error, response) {
9292 * @return {String }
9393 */
9494function _createNewFileName ( fileName ) {
95+ if ( ! config . renameFiles ) {
96+ return fileName ;
97+ }
9598 if ( _isParseHostedFile ( fileName ) ) {
9699 fileName = fileName . replace ( 'tfss-' , '' ) ;
97100 var newPrefix = crypto . randomBytes ( 32 / 2 ) . toString ( 'hex' ) ;
You can’t perform that action at this time.
0 commit comments