Status of legacy files on Parse S3
What will happen to file migration? I can't really find instructions on how to transfer/migrate over files to your own bucket.
We'll be working on a plan for this. Right now when you migrate data, the files stay on Parse's S3 bucket, but parse-server knows how to continue serving them..
It would be so nice to have a config setting with our own S3 settings which end up getting used for file uploads.
So we are assured that file migration will be happening? So that we can continue develop using PFFile before migration?
@hashmapped Yes
Without PFFile migration my apps are dead in the water, please prioritise this as it would allow me to migrate alot sooner
So if I do a database migration right now, when a user creates a new PFFile - will the MongoDB entry just point to a new file hosted by Parse or will something else happen ?
New files uploaded to parse-server are hosted in GridStore(Mongo), only files uploaded through api.parse.com are still hosted by Parse. We are definitely going to solve this, and an awesome engineer here is working on an great update.
+1 we really need this. Do we at least have a timeframe for this? like when it likely will be available?
Also would be good if the client SDK can directly upload to S3 without hoping on first to parse server, abstracted in the client so we can still use the parse file api.
I would love to see a script that helps the user (idempotently) download every file from Parse's S3 http://files.parsetfss.com/ endpoint and from GridFS, and uploads them to a third location of the user's choice (authentication might be an issue here of course — parse-server will need a way to handle this): whether this be an S3 bucket, or Dropbox, or Cloudinary, or whatever.
The script should also update the URL held in the relevant Mongo file field for each class.
It's scary to think that after a year, all files held on Parse will disappear unless action is taken!
@fatuhoku that is very easy, I have already written one to copy all my files off Parse to an alternative server for backup purposes. Just use the javascript or php api's and you will get it done in minutes.
The real issue is that until I move to my own server files uploaded to api.parse.com are hosted by Parse. What is needed is two fold.
- When I tell api.parse.com that I want to move to MongoDB - to move all my existing files over as well as the database and store them with MongoDB Gridstore.
- When (1) above is complete and I have moved to my own MongoDB for api.parse.com to store all new files to MongoDB gridstore and STOP hosting the files yourself.
This way I can follow Parse's guide of step 1) point at own database , 2) build own server, 3) issue app update.
Currently with files this is not possible.
An alternative (or additional) process could be telling both api.parse.com and the new parse server to host files on a S3 instance instead of MongoDB gridstore. Either way this is a glaring omission that needs resolving asap.
@chrisfoulds do you have that script to hand by any chance? I'd be grateful if you stuck it on a gist so that we all have something to work off. Re. new files hitting api.parse.com being stored there, I imagine you could write a Cloud Code function (for every class that has files...!) that saves them to GridDB explicitly.
Im not sure if its finished but in the FilesAdaptor.js you should abe able to set this to S3 soon. https://github.com/ParsePlatform/parse-server/blob/master/FilesAdapter.js see this bit of code for the s3 implementation https://github.com/ParsePlatform/parse-server/blob/master/S3Adapter.js .. I wish someone would document how to use this over gridstore. I personally haven't had time to test it out.
@gateway The S3Adapter seems to be working. I have not seen official documentation but here is a sample of my index.js. Note the additional require at the top to bring in the S3Adapter. It is noted in #113 that this may eventually be exposed by default so the require() won't be needed.
What happens when you use this adapter is that any new files added will go to your S3 bucket instead of GridFS in your MongoDB database.
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var S3Adapter = require('parse-server/S3Adapter');
...
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://.....',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: 'MY_APP_ID',
clientKey: 'MY_CLIENT_KEY',
masterKey: 'MY_MASTER_KEY',
filesAdapter: new S3Adapter(
"KEY",
"SECRET_KEY",
{bucket: "my-bucket-name", bucketPrefix: "some-folder/", directAccess: true}
)
});
@gfosco When can we expect an update on migrating existing files to a self-hosted S3 bucket? I have tested migration (and am using my fileKey) but all existing files result in a 404. The PFFile.url ends up pointing to a self hosted file instead of the parse hosted file.
Example URL:
http://foo.herokuapp.com/parse/files/dWOKPEJ9ihbPYARGV7lwBUz3vQOASuhfWrNl7PCtxrau/78a0a3aa-2ef3-46c8-be1b-14059308cc4a-my_image.jpg
I should note I am using the S3Adapter so that new files get stored to a self-hosted S3 bucket instead of GridFS. Is this resulting in the parse-server trying to also Retrieve files from my S3 instead of the existing parse hosted file?
The file migration solution will need to account for both existing files and new files. Existing files will ideally be able to be migrated to the same S3 bucket/folder as new files. If they cannot be migrated to the same self-hosted S3 bucket/folder as new files, the parse-server should work seamlessly for those of us opting to use the S3Adapter fileAdapter by delegating to some other S3 bucket for existing files and to the self-hosted S3 bucket for new files.
Thanks for helping us. So far things are working pretty smooth in general, but the PFFile question is a roadblock to finalizing migration.
@fatuhoku I am sure we'll get an awesome solution for migrating files from the Parse team. In the meantime (and for paranoid backup) I whipped a quick Python script to manually download files. To use it you'll need to export your collections to json using the "Export app data" option in your apps App Settings. Then you'll need to run the script for each file that contains pointers to files. It is a quick and dirty script that met my needs but it covers the basic requirements of a brute force file downloader. You'll very likely need to make some modifications to it to process your exported json files. https://gist.github.com/barnaclejive/bac711c85e5e9a94a8b1
@drew-gross @nlutsenko Thank you for sharing this.
Do we have plan to add adapter for other file storage services like Dropbox or Azure file storage ?
Immediate plans - no, but since it's fairly easy to create your own file adapter we would love to see the community build the ones that they think are the most helpful and we'll happily merge them.
Can we save the images (or files) on local server (E.g: http://domain.com/uploads/photo.png) instead of using S3 bucket?
You can do that in mongo using GridStoreAdapter (the default), or implement a new FileAdapter to store files on the local filesystem.