bbsimonbb
bbsimonbb

Reputation: 29020

When I upload to DigitalOcean Spaces with s3client, why do I get projectName.bucketName at the root of my path?

I'm getting started with Spaces. I'm successfully uploading images from a node backend with s3client and a PutObjectCommand. PutObjectCommand requires a Bucket argument, and it works when I put projectName.bucketName. To my surprise (and distaste), this argument is prepended to the Key, and so finds itself as a root folder in the interface, then repeated in the URL of the uploaded image. Why is this, and can I turn it off?

This is my upload command...

    const command = new PutObjectCommand({
        Bucket: "simplyfirst.simplyfirst",
        Key,
        Body: arr,
        ACL: "public-read",
        ContentType: contentType
    });
    try {
        const response = await s3Client.send(command);
        console.log(response);
        return NextResponse.json({newFilename:filename})
    } catch (err) {
        console.error(err);
        return new NextResponse("Error", { status: 500 })
    }

...which gives me this in Spaces...

image alt text

...and this as an url...

https://simplyfirst.ams3.digitaloceanspaces.com/simplyfirst.simplyfirst/cat/acme/acmePvc/products/GIJR0OqacAAZN_8.jpg

Upvotes: 1

Views: 90

Answers (0)

Related Questions