File Storage
Last updated
Was this helpful?
Last updated
Was this helpful?
This page will describe how to configure File Storage. For more details on how ScaffoldHub secures the file uploads and downloads, please read .
By default, ScaffoldHub saves the uploaded files on the temp directory of the server.
You will want to change the location to a persisted folder if you want to continue using the localhost strategy.
To do that, go to backend/src/services/file/localhostFileStorage.ts
and replace this variable:
If you plan on hosting your server on the cloud, is better to use a file storage provider on the cloud.
ScaffoldHub has two built-in cloud strategies: Google Cloud Storage and Amazon S3.
To use Google Cloud Storage, change the FILE_STORAGE_PROVIDER
variable fo the backend/.env file to use gcp.
Create a new project for the development environment.
Go to Storage > Browser and create a new Bucket.
Save the bucket name on the FILE_STORAGE_BUCKET
variable. The value must be your bucket-name.
In the example of this image, it will be scaffoldhub-doc-file-storage.appspot.com.
Now our app needs a service key to be able to access the bucket.
After you download the JSON file, you will see that it looks like this:
Now we must place this entire file into a single environment variable.
If you use VSCode, you can use the join lines
command.
Now place this line on theGOOGLE_CLOUD_PLATFORM_CREDENTIALS
variable.
Sign in to your account by calling gcloud auth login
.
Create a gcp-cors.json file on the same folder that you are at the command line.
Run this script. Make sure you replace the your-bucket-name by the bucket you created!
Done! You are now ready to use the Google Cloud File storage on your project.
To use Amazon S3, change the FILE_STORAGE_PROVIDER
variable fo the backend/.env file to use aws.
Go to Services > S3 and create a new bucket.
Make sure you do not block public files. Things like the workspace background image, workspace logo, and user avatar use files with public permissions for speeding purposes. Other files are by default private.
Save the bucket name on the FILE_STORAGE_BUCKET
variable.
Save the keys on the backend/.env file.
Go to the Amazon S3 console.
Go to Permissions > CORS configuration
Add this configuration:
Done! You are now ready to use the Amazon S3 storage on your project.
Go to and create an account.
Create a service account key that has permission to manage Google Cloud Storage buckets. Follow this: .
Install the .
Go to and create an account.
Create your AWS credentials by following this tutorial: .