Copy link to clipboard
Copied
I'm looking for a way to delete a file on amazon s3. I'm able to upload files no problem but I can't find any documentation on a deleteFile method. Does it exist?
In case this helps someone, here's the CFSCRIPT I use to upload a file after setting up the Amazon S3 cloud service in the administrator (NOTE: filekey is the directory in the bucket):
s3Service = getCloudService('awss3', 's3conf');
bucketObj = s3Service.root("MYBUCKET","true");
uploadStruct = {
"srcFile" : fullfilename,
"key" : filekey & cffile.serverFile,
"acl" : "PUBLIC_READ",
"metadata":{
"place":"us-east-2",
"deployment":"Production"
}
}
try{
uploadResponse=bucketObj.uploadFile(uploadStruct)
writeOutput("Object uploaded successfully")
writeDump(uploadResponse)
}
catch (any e){
writeOutput("Could not upload the object")
writeDump(e)
}
Copy link to clipboard
Copied
I have yet to deploy an application on the cloud. So I can only hazard a guess:
deleteStruct = {
"srcFile" : fullfilename,
"key" : filekey
};
try{
/* Alternative functions to try: deleteFile, fileDelete */
deleteResponse=bucketObj.delete(deleteStruct);
writeOutput("Object deleted successfully");
writeDump(deleteResponse);
}
catch (any e){
writeOutput("Could not delete the file");
writeDump(e);
}