Question

Securely provide credentials with aws-sdk/client-s3

I am working with a Laravel/Vue/Inertia project and trying to upload many pdfs/mp3s multi-part. I am trying to upload these using javascript and the aws sdk.

https://docs.digitalocean.com/products/spaces/how-to/use-aws-sdks/ I read through this article and it is loading a secret key through the node env vars. I would have to use vite env vars, I think. This isn’t secure.

How can I provide the credentials in a secure way?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
August 23, 2024

Heya,

A common and secure approach is to generate pre-signed URLs on the server side (Laravel), which your frontend (Vue.js with Inertia) can then use to upload files directly to DigitalOcean Spaces. This way, your sensitive credentials never touch the client-side code.

Regards

Spot on about env vars! While Vite env vars are convenient, they’re not ideal for secrets. Consider using a library like dotenv to load environment variables from a separate .env file that you exclude from version control.

I will take a different approach

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.