ServicesGoogle Cloud Storage

Google Cloud Storage

Installation

Install package

npm i @uplo/service-gcs

Add service to Uplo

import GCSService from '@uplo/service-gcs'
 
const uplo = Uplo({
  services: {
    google: new GCSService({
      isPublic: false,
      credentialsPath: path.resolve(
        __dirname,
        './config/gcp-credentials.json'
      ),
      bucket: process.env.GCS_BUCKET,
    }),
  },
})

Direct Upload

CORS

This is an example CORS configuration for direct uploads. To setup CORS, read a guide in Google Cloud Docs.

[
  {
    "origin": ["https://www.example.com"],
    "method": ["PUT"],
    "responseHeader": ["Origin", "Content-Type", "Content-MD5", "Content-Disposition"],
    "maxAgeSeconds": 3600
  }
]