DEV Community

Discussion on: 5 Minutes Tutorial Series - NodeJS upload files to Minio

Collapse
 
gokayokyay profile image
Gökay Okyay • Edited

Hello! The file url will be
MINIO_ENDPOINT:MINIO_PORT/BUCKET_NAME/FILE_NAME

Yes, you can save any file, not just images.

You can save the file’s url and the name to your db. However you need to be sure that file’s been uploaded successfully. In order to do that, save url and name of the file inside of the putObject method’s callback, after checking for the error ofc.

Collapse
 
dogancalli profile image
dogancalli • Edited

Hello it's me again :)
What am i doing wrong on my post method ?

app.post('/documents',(request, response) => {
    client.presignedPutObject('uploads', request.query.name, (err, url ,obj) => {
        dataAPI = {
                docName:$request.query.name,  
                docLink:"https://play.min.io:9000/uploads/"+request.query.name  
                }  
        response.send(dataAPI)
    })
});
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
gokayokyay profile image
Gökay Okyay

Hello!
It’s hard to tell just by looking at it but what’s with the dollar sign? Did you try to create a template literal? And it’ll be better gor you to check if any errors occurred.
Btw I didn’t use the presignedPutObject method on tutorial, have you read the docs? 😄