0

I recently switched over from deprecated multer-gcs to multer-google-storage. I have it mostly running, but cannot figure out how to make the files public. Is there a variable that I can set in the .env file? Right now I get the following when I go to the image page:

<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>
Anonymous caller does not have storage.objects.get access to example-app.appspot.com/xxx-yyy-zzz
</Details>
</Error

My code looks like this, and is properly saving everything, except that images are private:

const multer = require('multer');
var multerGoogleStorage = require("multer-google-storage");

dotenv.load({ path: '.env' });

var uploadHandler = multer({
  storage: multerGoogleStorage.storageEngine()
});

app.post('/sell', uploadHandler.any(), homeController.postSellPage);

.env File

GCS_BUCKET=example-project.appspot.com
GCLOUD_PROJECT=example-project
GCS_KEYFILE=./example-project-firebase-adminsdk-xxx.json
maudulus
  • 10,627
  • 10
  • 78
  • 117

1 Answers1

0

There are some options how to make the access public, so I would recommend you to take a look at the following doc and other posts on the community, on how to achieve that.

After that, you should be able to choose the best option for you and which one to follow.

Let me know if the information helped you!

gso_gabriel
  • 4,199
  • 1
  • 10
  • 22