I have just migrated my simple Parse app and database from Parse hosted services to Heroku (Parse-server-example) + MongoLab.
My simple app has a function to upload an image to a
I am just wondering how Parse-server-example and MongoLab together handle file upload and storage. I noticed that the
Thanks!
+1
@grassland-curing-cfa, yes, Parse Server supports file upload.
By default Parse Server uses the GridFileAdapter to store your file in your mLab database. The files are stored according to the GridFS specification of mongoDB.
More information here.
Alternatively you can store your file in a separate storage outside of your mongoDB database, e.g. in Amazon S3 or Google Cloud Storage. Your database will then only hold a reference to the file in that separate storage. One reason to do this can be that separate storage is often cheaper than storage in a managed database environment. To do that you specify a fileAdapter in index.js of your Parse Server.
More information here.
Thanks @mtrezza for the info.
There is documentation regarding S3 and Google Cloud Storage, but I am unable to find anything regarding how to set up a GridStoreAdapter with Parse-server-example. Are you able provide an example?
@grassland-curing-cfa, the fileAdapters are set-up in your Parse Server index.js file.
To use the GridStoreAdapter not extra set-up is required as this is the default storage when no fileAdapter is explicitly specified in your Parse Server initialization call in index.js.
To use another fileAdapter you specify it in your Parse Server initialization call. Below is an example for Amazon S3 storage fileAdapter specification where you would have to replace the parameters "S3_..." with your own:
...
var S3Adapter = require('parse-server').S3Adapter;
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
appId: process.env.APP_ID || 'APPLICATION_ID',
masterKey: process.env.MASTER_KEY || 'MASTER_KEY',
...
filesAdapter: new S3Adapter(
"S3_ACCESS_KEY",
"S3_SECRET_KEY",
"S3_BUCKET",
{directAccess: true}
),
...
});
You also need to set-up a S3 storage at Amazon. More info here
Similar procedure if you want to set-up a Google Cloud storage. More info here.
Please refer to Issue #1029 that I created yesterday regarding the GridStoreAdapter that I trialled. I didn't specify anything extra in the ParseServer constructor in the index.js file. After I ran the cURL command to upload some test image files, "fs.files" and "fs.chunks" were populated with a new document but the "chunkSize"is always 261120 regardless of the actual size of the file I uploaded. When I tried to open the uploaded using the returned URL it showed "Unable to display the file and it contains errors".
Any idea? Thanks so much!
I am closing this out as we're trying to cut down on the number of non-issues. This will help us focus on the issues that are actively preventing people from migrating their production apps to Parse Server.
You may use Server Fault for questions about managing Parse Server.
For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow.
@mtrezza The two links you have posted above for configuring cgs or s3 adapters link to the same place. I am currently trying to set up a cgs apapter and have managed to get a Parse-Server instance running so far but am sort-of stuck at the moment. Anything to point me in the right direction would be great!
Documentation for the fileAdapter is here now.
Most helpful comment
@grassland-curing-cfa, yes, Parse Server supports file upload.
By default Parse Server uses the GridFileAdapter to store your file in your mLab database. The files are stored according to the GridFS specification of mongoDB.
More information here.
Alternatively you can store your file in a separate storage outside of your mongoDB database, e.g. in Amazon S3 or Google Cloud Storage. Your database will then only hold a reference to the file in that separate storage. One reason to do this can be that separate storage is often cheaper than storage in a managed database environment. To do that you specify a fileAdapter in index.js of your Parse Server.
More information here.