Google cloud storage signedUrl generating error in NodeJS #11222
Unanswered
OlammieAO
asked this question in
General questions
Replies: 2 comments
-
Hello @OlammieAO - Could you please let us know if you are using Github hosted runners? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @OlammieAO - Could you please provide the logs for the issue? Also, here are a few things to check:
Thanks! Let me know if you need any help with these. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am working in nodejs to upload files(audio/video) and I want to be able to viewed the uploaded file from internet which I have set appropriate permission in the GCP Cloud Storage Bucket. I installed @google-cloud/storage package and upload file, the file i uploaded got uploaded successfully. I actually wanted to get the signedUrl of the uploaded file because I want to keep signedUrl(the public url) so that user can view the file from anywhere some other time.
*******WHAT I WANT TO ACHIEVE
I actually wanted to get the signedUrl of the uploaded file after uploading it because I want to keep signedUrl(the public url) so that user can view the file from anywhere some other time.
*******THE ERROR I GOT
Error: Cannot sign data without client_email. at GoogleAuth.sign (C:\Users\Documents\sample\node_modules\google-auth-library\build\src\auth\googleauth.js:788:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async sign (C:\Users\Documents\sample\node_modules@google-cloud\storage\build\cjs\src\signer.js:219:35) { name: 'SigningError' }
********WHAT I HAVE TRIED
I have set my command line google application credentials using the following command but no success:
set GOOGLE_APPLICATION_CREDENTIALS='test-project-sa.json'
Below are the code I have tried
npm install @google-cloud/storage
const uploadFile = async (fileToUpload, fileOutputName) =>{
try{
const bucket = storage.bucket(process.env.GCS_BUCKET_NAME);
})
const fileRef = await storage.bucket(process.env.GCS_BUCKET_NAME).file(
UserAvatars/${finalOutputFileName}
);//This line shows that the file was successfully updated, it logged to console
fileRef.exists().then(function (data) {
console.log("File in database exists ");
});
const response = await fileRef.getSignedUrl({
version: "v4",
action: "write",
expires: Date.now() + 15 * 60 * 1000, // 15 minutes
//contentType: filetype,
extensionHeaders: {
'x-goog-acl': 'public-read'
}
});
return publicUrl;
}catch(error){
console.log(error);
}
}
The file successfully got uploaded to the google cloud bucket but the SignedUrl cannot be generated. I have googled how to solve the client_email ut i couldn't get a comprehensive help.
Please how do i go about this?
Thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions