Transfers PFFiles hosted on parse.com (files.parsetffs.com) to your self-hosted parse-server by simply downloading, re-uploading them and saving the object again. Beware that this will cause all of your rows containing a PFFile to get a new updatedAt date
To run, make sure you install the dependencies using composer.phar install
Edit the constants found in migrate.php, also edit the $mapping
variable to match your classes and column names that contains PFFile's
define('SERVER_URL', 'http://example.com');
define('MOUNT_PATH', 'parse');
define('APPLICATION_ID', 'appid');
define('MASTER_KEY', 'masterkey');
define('OLD_PREFIX', 'http://files.parsetfss.com/'); // You can probably leave this one
$mapping = [
'_User' => [
'profileImage'
],
'UserFiles' => [
'SomeFileColumn', 'AnotherFileColumn'
]
];
With this setup, the script will connect to the parse-server at http://example.com/parse, loop over all profileImage
's in the _User
class and check if the files are still hosted at files.parsetfss.com, if they are, the file will be downloaded and then re-uploaded to your parse-server, after that, the object will be saved again - this time with the new URL to the file.
To run the script, simply open a terminal and enter php migrate.php
and sit back, it might take some time on large datasets.
- Since the object will be saved again, all objects that have their PFFiles re-uploaded will get a new updatedAt date
- Since objects are saved, any beforeSave and afterSave hooks will fire off. (These can return early if you simply check for usage of the masterKey)
If you found this simple script helpful, there is a beer fund located at paypal.me/mlmbrg