parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Parse server storage path ?

Open thamer898 opened this issue 10 years ago • 8 comments

Where parse server store media files like ( audio , video , image ) on server i need physical path ? can you help me with that ?

thamer898 avatar Feb 24 '16 18:02 thamer898

Be default, files are stored in GridStore, which is inside MongoDB. You can also use a FileAdapter like the S3Adapter we've provided to store files on Amazon S3, or implement your own adapter to store files anywhere else. We don't have a adapter for storing files on the filesystem yet, but if you implemented one we would be happy to add it to the repo :)

drew-gross avatar Feb 24 '16 19:02 drew-gross

How much MongoDb can store data ? on file system storage is it need any extra hard disk space ?

thamer898 avatar Feb 24 '16 19:02 thamer898

That depends on your hardware and mongo configuration and isn't a question I can answer.

drew-gross avatar Feb 24 '16 21:02 drew-gross

@drew-gross So i understand that in order to use Amazon for PFFiles we need to use the S3Adapter provided, instead of the default one (GridStore in MongoDB).

Can you provide me with an example how to achieve this ? As in how to use the S3Adapter and how to implement it rather than the default one ? I am new to JS, and i think a lot of Newbies like me will find this helpful.

Thank you.

georgesjamous avatar Mar 02 '16 07:03 georgesjamous

https://github.com/ParsePlatform/parse-server/wiki/Storing-Files-in-AWS-S3

drew-gross avatar Mar 02 '16 22:03 drew-gross

ohh, thank you for that. I followed all the steps and everything worked fine (storing and retrieving)

There is just one problem i am facing. Whenever i delete a whole Object or the PFFile from an Object (using iOS SDK), the Object gets updated but the files remain in AWS S3, they are not deleted. (this will cause garbage data; many unused Files will still be stored)

Is there any way to let the Parse-Server delete the files from S3 ? or it should and i am missing something ?

georgesjamous avatar Mar 04 '16 07:03 georgesjamous

This is done because we have no way of knowing if there is another object that references the same file. But if you know that there is no other reference to the file, you can call delete on it manually (currently only via the rest API, but we would be happy to accepts PRs in the SDKs to delete files)

drew-gross avatar Mar 04 '16 07:03 drew-gross

For any newbie out there like me, here's my snippet of Cloud Code to delete files from the default GridStore adapter before the original object is deleted (in that case you only delete the object once the file is deleted)-->you should modify areas where the asterisks appear

Parse.Cloud.beforeDelete('*Files*', function(request, response) {
Parse.Cloud.httpRequest({
    method: 'DELETE',
    url: 'http://insert servername here/parse/files/' + request.object.get("*UploadedFile*").name(),
    headers: {
      'X-Parse-Application-Id': '*xxxx*',
      'X-Parse-Master-Key': '*xxxx*'
    },
    success: function(httpResponse) {
      console.log(httpResponse.text);
      response.success();
    },
    error: function(httpResponse){
      console.error('Delete failed with response code ' + httpResponse.text);
      response.error()
    }
});

});

akramalakel avatar Dec 29 '16 17:12 akramalakel