简体   繁体   中英

How To Remove File After certain period from RackSpace Cloud using Asp.Net?

I am using 'net.openstack.Providers.Rackspace' to create object and save file to cloud.

I want to delete the newly uploaded file after 30 Days from RackSpace Cloud Automatically.

I have searched a lot about that and found 'X-Delete-After' metadata can be used. I am not able to get how to implement the same.

I am using following code to create object :

CloudFilesProvider cloudFilesProvider = GetCloudFileSytemObject();
cloudFilesProvider.CreateObject(strContainer, fupUploadStream, fileName);

Please help me regarding automatic deletion from cloud. Thanks

Finally I found the solution, Here is the code for the same

CloudFilesProvider cloudFilesProvider = GetCloudFileSytemObject();
Dictionary<string, string> dicMetadata = new Dictionary<string,string>();
dicMetadata.Add("X-Delete-After", "2592000");
cloudFilesProvider.CreateObject(strContainer, fupUploadStream, fileName, headers: dicMetadata);

Here '2592000(Seconds)' is equal to 30 Days.

This Code adds header to file 'X-Delete-At' with self calculation of date time of file to be deleted.

Now after the time we want to delete we are able to delete the file content , But file it self is not deleted.

I am searching for the same and trying to contact RackSpace Cloud.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM