ParthKansara February 2016

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

Answers


ParthKansara February 2016

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.

Post Status

Asked in February 2016
Viewed 1,496 times
Voted 9
Answered 1 times

Search




Leave an answer