title: How to create subdirectory in amazon s3 bucket
body: <p>i am using Amazon S3 Web-services and not able to create sub directory on my bucket.</p>
  
  <p>i want something like that </p>
  
  <p>when user upload the files, a sub directory create on S3 Bucket with the name of  user id and files are stored into the sub directory .</p>
  
  <p>i am using the following code </p>
  
  <pre><code> AmazonS3Client s3Client = new AmazonS3Client("AWSAccessKey", "AWSSecretKey", Amazon.RegionEndpoint.APSoutheast1);  
  
      protected void btnUpload_Click(object sender, EventArgs e)
      {
  
          if (!string.IsNullOrEmpty(fileUpload.FileName))
          {
              //Saving File to local disk folder.
              string filePath = Server.MapPath("aa") + "\\" + fileUpload.FileName;
              string fileExtension = fileUpload.FileName.Substring(fileUpload.FileName.LastIndexOf(".") + 1);
              fileUpload.SaveAs(filePath);
              string contentType = GetContentType(fileExtension);    
  
              //Push the given object into S3 Bucket
              PutObjectRequest objReq = new PutObjectRequest
              {
                  Key = fileUpload.FileName,
                  FilePath =  filePath,
                  ContentType = contentType,
                  BucketName = "datastore.MyData",
                  CannedACL = S3CannedACL.Private,               
  
              };
  
              PutObjectResponse response = s3Client.PutObject(objReq);
              if (response.ETag != null)
              {
                  string etag = response.ETag;
                  string versionID = response.VersionId;
                  Response.Write("&lt;script&gt;alert('File uploaded to S3 Bucket Successfully.');&lt;/script&gt;");
              }
              //Deleting Localy Saved File
              if (File.Exists(filePath))
              {
                  File.Delete(filePath);
              }
          }
      }
      private string GetContentType(string fileExtension)
      {
          string contentType = string.Empty;
          switch (fileExtension)
          {
              case "bmp": contentType = "image/bmp"; break;
              case "jpeg": contentType = "image/jpeg"; break;
              case "jpg": contentType = "image/jpg"; break;
              case "gif": contentType = "image/gif"; break;
              case "tiff": contentType = "image/tiff"; break;
              case "png": contentType = "image/png"; break;
              case "plain": contentType = "text/plain"; break;
              case "rtf": contentType = "text/rtf"; break;
              case "msword": contentType = "application/msword"; break;
              case "zip": contentType = "application/zip"; break;
              case "mpeg": contentType = "audio/mpeg"; break;
              case "pdf": contentType = "application/pdf"; break;
              case "xgzip": contentType = "application/x-gzip"; break;
              case "xcompressed": contentType = "applicatoin/x-compressed"; break;
          }
          return contentType;
      }
  </code></pre>
  
  <p>Please help me to achieve this. </p>