如何在Swisscom Application Cloud上提供用户上传的文件?

时间:2021-03-26 10:35:50

As applications shouldn't write files to the local file system it makes sense to store user-uploaded files in the Dynamic Storage provided by Swisscom.

由于应用程序不应将文件写入本地文件系统,因此将用户上载的文件存储在Swisscom提供的Dynamic Storage中是有意义的。

The Dynamic Storage service is similar to Amazon S3 where you would usually make the bucket with the user-uploaded files publicly readable with a bucket policy.

动态存储服务类似于Amazon S3,您通常可以使用存储桶策略使用户上载的文件可以公开读取。

However how would I serve user-uploaded files from the Dynamic Storage as the "Put Bucket policy" is an unsupported operation?

但是,我如何从动态存储中提供用户上传的文件,因为“Put Bucket策略”是不受支持的操作?

1 个解决方案

#1


3  

You are correct, dynamic storage of Swisscom does not support the „PUT bucket policy“ operation. But you can serve files directly to the user by generating pre-signed URLs.

您是对的,Swisscom的动态存储不支持“PUT桶策略”操作。但您可以通过生成预签名URL直接向用户提供文件。

See Share an Object with Others

请参阅与他人共享对象

All objects by default are private. Only the object owner has permission to access these objects. However, the object owner can optionally share objects with others by creating a pre-signed URL, using their own security credentials, to grant time-limited permission to download the objects.

默认情况下,所有对象都是私有只有对象所有者才有权访问这些对象。但是,对象所有者可以选择通过使用自己的安全凭证创建预签名URL来与其他人共享对象,以授予下载对象的时间限制权限。

When you create a pre-signed URL for your object, you must provide your security credentials, specify a bucket name, an object key, specify the HTTP method (GET to download the object) and expiration date and time. The pre-signed URLs are valid only for the specified duration.

为对象创建预签名URL时,必须提供安全凭据,指定存储桶名称,对象密钥,指定HTTP方法(下载对象的GET)以及到期日期和时间。预签名URL仅在指定的持续时间内有效。

Anyone who receives the pre-signed URL can then access the object. For example, if you have a video in your bucket and both the bucket and the object are private, you can share the video with others by generating a pre-signed URL.

接收预签名URL的任何人都可以访问该对象。例如,如果您的存储桶中有视频且存储桶和对象都是私有的,则可以通过生成预先签名的URL与其他人共享视频。

By using a pre-signed URL you have to define how long the URL shall be valid. We recommend to choose an expiration date that makes sense for the specific use-case.

通过使用预先签名的URL,您必须定义URL的有效期。我们建议选择对特定用例有意义的到期日期。

Info: currently the S3 storage is powered by Atmos

信息:目前S3存储由Atmos提供支持

#1


3  

You are correct, dynamic storage of Swisscom does not support the „PUT bucket policy“ operation. But you can serve files directly to the user by generating pre-signed URLs.

您是对的,Swisscom的动态存储不支持“PUT桶策略”操作。但您可以通过生成预签名URL直接向用户提供文件。

See Share an Object with Others

请参阅与他人共享对象

All objects by default are private. Only the object owner has permission to access these objects. However, the object owner can optionally share objects with others by creating a pre-signed URL, using their own security credentials, to grant time-limited permission to download the objects.

默认情况下,所有对象都是私有只有对象所有者才有权访问这些对象。但是,对象所有者可以选择通过使用自己的安全凭证创建预签名URL来与其他人共享对象,以授予下载对象的时间限制权限。

When you create a pre-signed URL for your object, you must provide your security credentials, specify a bucket name, an object key, specify the HTTP method (GET to download the object) and expiration date and time. The pre-signed URLs are valid only for the specified duration.

为对象创建预签名URL时,必须提供安全凭据,指定存储桶名称,对象密钥,指定HTTP方法(下载对象的GET)以及到期日期和时间。预签名URL仅在指定的持续时间内有效。

Anyone who receives the pre-signed URL can then access the object. For example, if you have a video in your bucket and both the bucket and the object are private, you can share the video with others by generating a pre-signed URL.

接收预签名URL的任何人都可以访问该对象。例如,如果您的存储桶中有视频且存储桶和对象都是私有的,则可以通过生成预先签名的URL与其他人共享视频。

By using a pre-signed URL you have to define how long the URL shall be valid. We recommend to choose an expiration date that makes sense for the specific use-case.

通过使用预先签名的URL,您必须定义URL的有效期。我们建议选择对特定用例有意义的到期日期。

Info: currently the S3 storage is powered by Atmos

信息:目前S3存储由Atmos提供支持