DEV Community

Cover image for Use Contabo Object Storage with NodeJS

Use Contabo Object Storage with NodeJS

EinLinuus on March 29, 2022

Hi there! 👋 Recently, Contabo launched their new storage solution Object Storage. These object storages provide an S3 compatible API and can be us...
Collapse
 
ramprogrammer profile image
Hanuma

Dear Ein,

It was really helpful article for a beginner like me.
I want to share something.
documenter.getpostman.com/view/174...

In contabo, we add user from web console. Is it possible to add user from JS running in browser? Apologies if my question is naive.

Thanks for your practical article.

Collapse
 
einlinuus profile image
EinLinuus

Thanks for your feedback!
I'm not exactly sure if I understand correctly, but maybe this can help?
api.contabo.com/#operation/createUser

I'd recommend to not do this from the browser, as you have to send your API token / credentials along with the request and users of your website would be able to steal it and execute whatever action they want.

Collapse
 
ramprogrammer profile image
Hanuma

Hey EinLinuus..
that link was very useful.

I wonder how users upload to their object storage buckets without knowing token details on cloud backup websites. they register and start uploading . If I figure it out, I will come back and let you know.
thanks for your time EinLinuus.

Collapse
 
alperuyanik profile image
Alper Uyanık

Great work here, thank you. Can you post the same content but for python-flask version?

Collapse
 
einlinuus profile image
EinLinuus

I'm not a python programmer, but I tried my best 😊 I've attached a python-flask version to the end below the NodeJS source code. I won't create a post specific for that python version as I don't want to teach something I don't really know myself.

dev.to/einlinuus/use-contabo-objec...

Collapse
 
faizal_martinus_2062af7d1 profile image
Faizal Martinus

Hi, thank you for the insight. Do you know how to upload file with Public Sharing? I tried putObjectAcl, and then ACL: 'public-read', but unsuccessful

Collapse
 
einlinuus profile image
EinLinuus

Hmm, I don't know how to specify that when uploading files, but I'll look into it. I just created a bucket for all public data (in my case only images) and set the whole bucket to public reading

Collapse
 
faizal_martinus_2062af7d1 profile image
Faizal Martinus

Thanks! I guess setting the bucket for public reading is the only way.

Collapse
 
eliranbenishai profile image
Eliran

Thank you for the article, extremely helpful. Any news regarding the public access of uploads? I'm still struggling with this and none of the S3 documentation seems to apply to Contabo's case.

Collapse
 
urielsouza29 profile image
Uriel dos Santos Souza • Edited

Hi!
Upload with pre-signed url?
Download with pre-signed url?
with nodejs
with the packages @aws-sdk/client-s3, @aws-sdk/s3-request-presigner?

hugs

Collapse
 
xyba profile image
xyba

Thank you so much for this!
An update using client-s3 would be highly appreciated!!

Collapse
 
nperez96 profile image
Néstor Pérez

s3BucketEndpoint is no longer available on s3 client config, this method no longer works :(

Collapse
 
nperez96 profile image
Néstor Pérez

You need to use {
region: 'default',
endpoint: process.env.S3_ENDPOINT,
disableS3ExpressSessionAuth: true,
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
},
forcePathStyle: true,
}

Now.