简体   繁体   English

获取新上载的CloudFiles资产的公共URL

[英]Getting public URL of newly uploaded CloudFiles asset

When uploading new asset into the CloudFiles storage I want to get public URL of this asset (if container is CDN-enabled). 将新资产上传到CloudFiles存储时,我想获取此资产的公共URL(如果容器已启用CDN)。 I figured out the only way to do this is to issue 3 (yes, three!) requests to RackSpace: 我想出了这样做的唯一方法是向RackSpace发出3个(是的,3个!)请求:

  1. Authenticate user and get x-auth-token , x-storage-url and x-cdn-management-url . 验证用户并获取x-auth-tokenx-storage-urlx-cdn-management-url
  2. After getting all the tokens and URLs, upload a file to the container. 获取所有令牌和URL后,将文件上传到容器。
  3. Issue a HEAD request to the x-cdn-management-url for public URL of the container. x-cdn-management-url发出HEAD请求以获取容器的公共URL。

I just want to make sure that I really need 3 requests per upload to get the public URL of the asset I just uploaded. 我只是想确保每次上传我真的需要3个请求来获取我刚刚上传的资产的公共URL。 All the operations must be performed programmatically via API. 必须通过API以编程方式执行所有操作。

I believe that once you have your container's CDN URL, every object you put in it is appended to it. 我相信,一旦你拥有容器的CDN URL,你输入的每个对象都会附加到它上面。 So, if your container's CDN URL is cdn1.foo.cloudstorage.com , your objects will have the URLs cdn1.foo.cloudstorage.com/object1.ext , cdn1.foo.cloudstorage.com/object2.ext , etc. 所以,如果你的容器的CDN网址是cdn1.foo.cloudstorage.com ,你的对象将有网址cdn1.foo.cloudstorage.com/object1.extcdn1.foo.cloudstorage.com/object2.ext等。

You only need the three steps to get the initial container CDN URL. 您只需要三个步骤即可获取初始容器CDN URL。 Afterwards, it's simple. 之后,这很简单。

If you're using Java, PHP, or Python, checkout one of the Rackspace SDKs . 如果您使用的是Java,PHP或Python,请检查其中一个Rackspace SDK For examples on how to use CDN with each see: 有关如何使用CDN的示例,请参阅:

  1. Java: CloudFilesPublish.java Java: CloudFilesPublish.java
  2. PHP: cdn.php PHP: cdn.php
  3. Python: container_cdn.py Python: container_cdn.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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