Unable to access google cloud storage in heroku

Asked 2 years ago, Updated 2 years ago, 101 views

using express.
I tried to upload the file to google cloud storage with heroku, but I couldn't.
Issue an error statement in the following locations:

const blobStream=blob.createWriteStream()

However, since it works fine locally, I think the gcs key setting is strange.

/api
  index.js// I'm running it here
//Procfile
echo${GOOGLE_CREDENTIALS}>/google-credentials.json
web:nuxt start
//index.js
consto = new Storage()
//env
goOGLE_APPLICATION_CREDENTIALS —google-credentials.json
GOOGLE_CRENDENTIALS: "Key"

If I set GOOGLE_APPLICATION_CREDENTIALS, is there nothing I need for new Storage()?
Or is the file specification wrong?
Thank you for your cooperation.

2020-12-06T 12:48:41.864878+00:00 app [web.1]: Unexpected end of JSON input
2020-12-06T 12:48:41.864890 + 00:00 app [web.1]:
2020-12-06T 12:48:41.864891 + 00:00 app [web.1]: at JSON.parse(<anonymous>)
2020-12-06T12:48:41.864892 + 00:00 app [web.1]: at ReadStream.<anonymous>(node_modules/google-auth-library/build/src/auth/googleauth.js:334:39)
2020-12-06T 12:48:41.864893 + 00:00 app [web.1]: at ReadStream.emit (events.js:326:22)
2020-12-06T12:48:41.864894 + 00:00 app [web.1]: at ReadStream.EventEmit.emit (domain.js:483:12)
2020-12-06T 12:48:41.864894 + 00:00 app [web.1]: at endReadableNT(_stream_readable.js:1241:12)
2020-12-06T12:48:41.864895 + 00:00 app [web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21)

nodejs —12.19.0
express:4.17.1

node.js google-cloud-storage

2022-09-30 18:12

2 Answers

The environment variable GOOGLE_CREMENTIALS specified below is not JSON, so JSON.parse appears to be spouting an error.

 echo${GOOGLE_CREDENTIALS}>/google-credentials.json

GOOGLE_CREDENTIALS is JSON.parseCheck to see if possible text is retained.


2022-09-30 18:12

Sorry for the trouble.
In the first place,

 echo${GOOGLE_CREDENTIALS}>/app/google-credentials.json

The file you saved was .procfile.


2022-09-30 18:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.