Getting the public URL of a newly created object
I can't find this anywhere in the documentation or API, so I'll just ask. CloudFilesProvider.CreateObject is a void function, and so returns no information about the object it just created. How can I get the public URL of an object created with CreateObject?
I was actually able to figure this out by doing this:
cloudFilesProvider.CreateObject(cloud_container, stream, objectName, region: "DFW", headers: new Dictionary<string, string> { { CloudFilesProvider.DetectContentType, "True" } });
var meta = cloudFilesProvider.GetContainerCDNHeader(cloud_container, region: "DFW");
return meta.CDNSslUri + "/" + objectName;
However, those URLs only ever get me 0 byte files after these uploads "succeed"...
Also, in the .NET CreateObject example here (https://developer.rackspace.com/docs/cloud-files/getting-started/), what is the point of reading the FileStream into a byte[] if you don't use it when calling CreateObject?
Turns out the uploads were succeeding, but I wasn't setting stream.Location back to 0 before calling CreateObject.
@mlb5000 Sorry I didn't get back to you sooner. You make some great points here, so I'm reopening the issue until I can look into some ways to make this easier for future developers.
- We definitely need to revisit the documentation in the linked example. I opened rackerlabs/developer.rackspace.com#958 to track progress on this.
- The public URI is an interesting situation, and I'm not quite sure how best to handle it. In particular, while the
CreateObjectoperation is a fundamental part of the OpenStack Object Storage Service v1 (which all OpenStack-compatible vendors would use), the public URI functionality is Rackspace-specific and even goes through a different service endpoint altogether. It's important to make sure the public URI functionality does not affect non-Rackspace users of the SDK, but like you mentioned, it's also important for Rackspace users to have straightforward access to this information.
well at least I'm not missing anything fundamental in the API. I'm in the process of porting a PHP application into .NET that uses the PHP rackspace library, so sometimes come across missing features like this.
one thing I noticed is that the scenario I proposed above does not work if the container doesn't have CDN enabled. For some of our containers that's the case, and so I had to resort to using a hardcoded https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS URL prefix