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

Does CF2021 cloudservice have a deleteFile method?

New Here ,
Nov 07, 2021 Nov 07, 2021

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

Views

50

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

 

Votes

Translate

Translate

Report

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
Documentation