Is your feature request related to a problem? Please describe.
Include support for Digital Ocean Spaces as one of the file adapters.
Describe the solution you'd like
Just as simple as any other existing adapters.
const spacesAdapter = require('parse-server').spacesAdapter;
new ParseServer({
filesAdapter: new spacesAdapter({ ...config }),
});
Describe alternatives you've considered
None exists yet, to consider.
Did you have a look at the file system storage adapter? This seems to be the one you need. D.O. Storage is similar to AWS block storage and are just attached volumes on your instance. I鈥檓 not sure how multiple instances referencing the same volume in read/write would work, but from what I can see, the FS adapter, pointing to the right folder on the volume should do the job.
I think I need to edit my question. The S3 equivalent seems to be Digital Ocean Spaces.
Volumes are Block Storage product, allowing you to attach additional SSD to the Droplet.
Spaces are Object Storage product. Spaces aren't associated with any Droplet, you can access anywhere, using any S3-compatible utility.
Excellent, it鈥檚 compatible with S3, so probably, we would either use the S3Adapter with a new customization point for the remote URL to send the data to DO instead of AWS.
That should work.
Some reference: https://developers.digitalocean.com/documentation/spaces/#introduction
Hi, I did something like that to specify the remote URL of DO :
var express = require("express");
var ParseServer = require("parse-server").ParseServer;
var path = require("path");
var S3Adapter = require("@parse/s3-files-adapter");
var AWS = require("aws-sdk");
//Configure Digital Ocean Spaces EndPoint
const spacesEndpoint = new AWS.Endpoint(process.env.SPACES_ENDPOINT);
var s3Options = {
bucket: process.env.SPACES_BUCKET_NAME,
baseUrl: process.env.SPACES_BASE_URL,
region: process.env.SPACES_REGION,
directAccess: true,
globalCacheControl: "public, max-age=31536000",
bucketPrefix: process.env.SPACES_BUCKET_PREFIX,
s3overrides: {
accessKeyId: process.env.SPACES_ACCESS_KEY,
secretAccessKey: process.env.SPACES_SECRET_KEY,
endpoint: spacesEndpoint
}
};
var s3Adapter = new S3Adapter(s3Options);
var api = new ParseServer({
databaseURI: process.env.DATABASE_URI || "mongodb://localhost:27017/dev",
cloud: process.env.CLOUD_CODE_MAIN || __dirname + "/cloud/main.js",
appId: process.env.APP_ID || "myAppId",
masterKey: process.env.MASTER_KEY || "",
serverURL: process.env.SERVER_URL || "http://localhost:1337/parse",
logLevel: process.env.LOG_LEVEL || "info",
allowClientClassCreation: false,
filesAdapter: s3Adapter,
}
});
If it can help !
I will give it a try and let you know. Thanks for this @Tybi
@Tybi if you can, adding this to a PR on the S3 adapter repo would be nice
@flovilmart Ok ! I will do this this week !
Thanks @Tybi ! I believe this can go into the docs repo as well, where the guide for setting up is
Hi, @Tybi thanks, i can run using passing as an instance, but how i can use using config file (pm2 json)?
Starting which Parse-Server version are DO Spaces supported, couldn't find this in the changelog.
Another option is to add the following additional file as an adapter:
var AWS = require("aws-sdk");
var S3Adapter = require('@parse/s3-files-adapter');
class DOSpacesFileAdapter extends S3Adapter {
constructor(...args) {
//Set Digital Ocean Spaces EndPoint
const spacesEndpoint = new AWS.Endpoint(process.env.SPACES_ENDPOINT);
//Define S3 options
var s3Options = {
bucket: process.env.SPACES_BUCKET_NAME,
baseUrl: process.env.SPACES_BASE_URL,
region: process.env.SPACES_REGION,
bucketPrefix: process.env.SPACES_BUCKET_PREFIX,
s3overrides: {
accessKeyId: process.env.SPACES_ACCESS_KEY,
secretAccessKey: process.env.SPACES_SECRET_KEY,
endpoint: spacesEndpoint
}
};
super(s3Options);
}
}
module.exports = DOSpacesFileAdapter;
module.exports.default = DOSpacesFileAdapter;
If you are using parse-server in a docker container, you can even mount the file as part of the container under _/parse-server/lib/Adapters/Custom/_ and reference it via PARSE_SERVER_FILES_ADAPTER=_./Custom/DOSpacesFileAdapter.js_