title: How to do delete folder or file through requests s3 in digitalocean space
body: <p>I trying to handle a great service called Space in Digital Ocean. <a href="https://www.digitalocean.com/community/tutorials/how-to-upload-a-file-to-object-storage-with-node-js" rel="nofollow noreferrer">Here</a> is a pretty nice explanation about uploading files, but there is only about GET request and nothing about DELETE. Maybe someone has got experience with S3 together with Digital Ocean Space on Node JS?</p>
  
  <p>Using localhost server I found out in settings of Space that "Advanced CORS Options" you can provide "Origin" and only "Allowed Methods" GET.
  But PUT, DELETE, POST, HEAD is disable.</p>
  
  <p>Here is what I trying:</p>
  
  <pre><code>export default {
    upload: (req, res) =&gt; {
      const storage = multerS3({
        s3,
        bucket,
        contentType: multerS3.AUTO_CONTENT_TYPE,
        acl: 'public-read',
        key: function(req, file, callback) {
          const { email } = req.user;
  
          callback(null, email + '/' + file.originalName);
        },
      });
  
      const upload = multer({ storage }).array('upload', 3);
  
      upload(req, res, err =&gt; {
        if (err) {
          return res.status(422).send({
            errors: [{ title: 'Image Upload Error', detail: err.message }],
          });
        } else {
          console.log('Success upload file');
        }
        res.end();
      });
    },
  
    delete: (req, res) =&gt; {
      const params = { Bucket: bucket, Key: 'some-folder-name-here' };
      s3.deleteObjects(params, function(err, data) {
        if (err) {
          return res.send({ error: err });
        }
        res.send({ data });
      });
    }
  }
  </code></pre>
  
  <p>Actually it should be great if it's gonna be possible to delete and upload files through my localhost using simple s3 api.</p>
  
  <p>Thank you.</p>
  
  <p>UPDATE:</p>
  
  <p>Mistake was here: <code>s3.deleteObjects</code>, have to use <code>s3.deleteObject</code>, and yes, have to use in <code>Key</code> whole path without bucket name.
  Perfect explain <a href="https://medium.com/dailyjs/digital-ocean-spaces-pros-cons-and-how-to-use-it-with-javascript-1802559ce2bd" rel="nofollow noreferrer">here</a>. Thanks everyone.</p>