title: How can I delete folder on s3 with node.js?
body: <p>Yes, I know. There is no folder concept on s3 storage. but I really want to delete a specific folder from s3 with node.js. I tried two solutions, but both didn't work.
  My code is below:
  Solution 1:
  Deleting folder directly.</p>
  
  <pre><code>var key='level/folder1/folder2/';
  var strReturn;
          var params = {Bucket: MyBucket};
          var s3 = new AWS.S3(params);
          s3.client.listObjects({
              Bucket: MyBucket,
              Key: key
          }, function (err, data) {
              if(err){
                  strReturn="{\"status\":\"1\"}";
  
              }else{
                  strReturn=+"{\"status\":\"0\"}";
              }
              res.send(returnJson);
              console.log('error:'+err+' data:'+JSON.stringify(data));
          });
  </code></pre>
  
  <p>Actually, I have a lot of files under folder2. I can delete single file from folder2 if I define key like this:
  var key='level/folder1/folder2/file1.txt', but it didn't work when I deleted a folder(key='level/folder1/folder2/').
  Solution 2:
  I tried to set expiration to an object when I uploaded this file or folder to s3. code is below:</p>
  
  <pre><code>s3.client.putObject({
                  Bucket: Camera_Bucket,
                  Key: key,
                              ACL:'public-read', 
                  Expires: 60 
              }
  </code></pre>
  
  <p>But it didn't either. After finishing uploading, I checked the properties of that file. it showed there was nothing value for expiry date:</p>
  
  <pre><code>Expiry Date:none
  Expiration Rule:N/A
  </code></pre>
  
  <p>How can I delete folder on s3 with node.js?</p>