I'm using Rackspace OpenStack Cloud Files API. The upload itself works without any issues but there is an issue with updating MetaData for the object. After calling the CreateObject method, the file has correct headers but it changes the content-type header after calling UpdateObjectMetadata on the same object. Not sure what I'm doing wrong here.
void Test(string containerName, Stream objectStream, string name, string region)
{
_cloudFilesProvider.CreateObject(containerName, objectStream, name, region: region);
// debug only
var metaData = _cloudFilesProvider.GetObjectMetaData(containerName, name, region);
_cloudFilesProvider.UpdateObjectMetadata(containerName, name, new Dictionary<string, string>
{{"Mimetype", "image/png"},
{"Size", "500"},
{"FileName", "TestImage.png"},
{"Dimensions", "128x128"} }, region);
// debug only
metaData = _cloudFilesProvider.GetObjectMetaData(containerName, name, region);
}
These are the metaData variable's before and after values. See how the content-type changes from image/png to application/json?
Before
[0]: {[x-timestamp, 1379752874.71586]}
[1]: {[x-trans-id, txf1bbd8a40b604f9a81140-00523d5bb4syd2]}
[2]: {[accept-ranges, bytes]}
[3]: {[content-length, 159340]}
[4]: {[content-type, image/png]}
[5]: {[date, Sat, 21 Sep 2013 08:41:24 GMT]}
[6]: {[etag, 375cd8b405058f2766482345d4adbd0e]}
[7]: {[last-modified, Sat, 21 Sep 2013 08:41:14 GMT]}
After
[0]: {[x-timestamp, 1379752926.55112]}
[1]: {[x-trans-id, tx269335ba878f44db890a1-00523d5be2syd2]}
[2]: {[accept-ranges, bytes]}
[3]: {[content-length, 159340]}
[4]: {[content-type, application/json]}
[5]: {[date, Sat, 21 Sep 2013 08:42:10 GMT]}
[6]: {[etag, 375cd8b405058f2766482345d4adbd0e]}
[7]: {[last-modified, Sat, 21 Sep 2013 08:42:06 GMT]}
Edit: As a temporary workaround I am using CreateObject method to modify the headers with the metadata. It's actually better this way as it saves an unnecessary POST. In fact, the CreateObject method should probably support an optional parameter for setting MetaData. Thoughts?
cloudFilesProvider.CreateObject(containerName, objectStream, name, headers: new Dictionary<string, string>
{{"X-Object-Meta-Mimetype", "image/png"},
{"X-Object-Meta-Size", "500"},
{"X-Object-Meta-FileName", "TestImage.png"},
{"X-Object-Meta-Dimensions", "128x128"} }, region: region);