Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

df-messenger.js upload file to Bucket

Hi everyone,

I'm currently working through this (URL Removed by Staff) on uploading files to a Google Cloud Storage bucket and then applying Gemini 1.0 Pro Vision to it.

At the moment, I'm primarily focused on the file upload portion. The instructions work well, but they require the bucket to be public, which raises some security concerns.

mateus_exel_0-1723034062727.png

Here’s the JavaScript code provided in the blog post:

 

<script>
globalThis.dfInstallUtils({
'gcs-bucket-upload': {bucketName: '[your-bucket-name]'},
});
const dfMessenger = document.querySelector('df-messenger');
dfMessenger.addEventListener('df-file-upload-completed', function (event) {
dfMessenger.sendRequest('query','file uploaded');
});
</script>

Although the chatbot will only be available in logged-in areas, I don’t consider keeping the bucket public to be a best practice.

Does anyone have recommendations on how to securely handle the file uploads without making the bucket public? Also, what modifications should I make to dfInstallUtils to ensure secure access?

Thank you very much for your help!

0 2 488
2 REPLIES 2

Hi @mateus_exel,

Welcome to Google Cloud Community!

You may consider implementing public access prevention to restrict public access to your buckets and objects. You may check also this documentation on how to use this and apply them based on your use case.

Hope this helps.

Hi @cassandramae, Thanks for sharing!
Do you know what alterations would be needed on the client side?
what do I have to add to the gcs-bucket-upload dictionary?