public boolean createFolder(String path) { try { // create meta-data for your folder and set content-length to 0 ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(0); // create empty content InputStream emptyContent = new ByteArrayInputStream(new byte[0]); // create a PutObjectRequest passing the folder name suffixed by / PutObjectRequest putObjectRequest = new PutObjectRequest(this.bucketName, path + SUFFIX, emptyContent, metadata); // send request to S3 to create folder boolean doesObjectExist = this.s3client.doesObjectExist(bucketName, path); if (!doesObjectExist) { this.s3client.putObject(putObjectRequest); } return true; } catch (Exception e) { return false; } }
return
public boolean createFolder(String path) { return true; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)