Report this

What is the reason for this report?

Upload success with DO space but never show

Posted on April 4, 2019

I’m using DO space for the first time to upload images and documents. I used multer and multer-s3 to upload multiple images. The function works fine and show successful without error. But DO space doesn’t show any updates. The files doesn’t upload to the DO space. I tried URL but no such key.

I set my DO Space:

  • Enable File Listing
  • Enable CDN
  • CORS: allow all the wildcard domain
const bucket = 'MY_DO_UNIQUE_NAME';
const spacesEndpoint = new AWS.Endpoint('sgp1.digitaloceanspaces.com');
const s3 = new AWS.S3({
        endpoint: spacesEndpoint,
        accessKeyId: process.env.DO_ACCESS_KEY,
        secretAccessKey: process.env.DO_SECRET_KEY
 });

const upload = multer({
      storage: multerS3({
        s3:s3,
        bucket: bucket,
        acl: 'public-read',
        key: function (request, file, cb) {
          console.log(file);
          cb(null, file.originalname);
        }
      }),

}).array('file', 100);

upload(req, res, function (error, file, data) {
          if (error) {
            console.log(error);
            return response.redirect("/error");
          }
          console.log('File uploaded successfully.');
});


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!

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.

Hello! I’m having a similar problem but in my case I get the return above but my files are unreadable in spaces. I use the AWS api.

Greetings!

I’m sorry about the trouble this is causing for you. My concern is that perhaps your code is not putting out an error, but that this may not be a clear indication that our server has actually accepted the upload. Are you able to fully output the response from our server when you upload the object? Here’s an example of what a successful response might look like to a PUT:

HTTP/1.1 200 OK

Date: Mon, 10 Jul 2017 19:46:06 GMT
x-amz-request-id: tx0000000000000027bd57c-005963d97e-1268c-nyc3a
Content-Length: 0
Accept-Ranges: bytes
Last-Modified: Mon, 10 Jul 2017 19:05:09 GMT
Etag: "fb08934ef619f205f272b0adfd6c018c"
Connection: close

Jarland

Hi,

Same problem! Impossible upload a file with DO Space., but same code works on my AWS S3.

Help please…

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.