Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Does CF2021 cloudservice have a deleteFile method?

New Here ,
Nov 07, 2021 Nov 07, 2021

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)
}

138
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2021 Nov 11, 2021
LATEST

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);
}
         

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources