amazon-s3 - 如何使用 Google Cloud Storage 隐藏真实 URL?

标签 amazon-s3 azure-storage google-cloud-storage

场景:我将一些文件放在 Google 网络存储上。

而且我希望只有付费用户才能下载此文件。所以我的问题是,如何向付费用户隐藏此文件以防止他们与其他未付费用户共享此 URL。

那么,有没有办法隐藏真实的文件位置呢?一次性或限时 URL 或任何其他?

其他 CDN 提供商可能会隐藏 URL - MIcrosoft Azure Storage 或 Amazon S3?

最佳答案

Amazon S3为此提供查询字符串身份验证(通常称为预签名 URL),请参阅 Using Query String Authentication :

Query string authentication is useful for giving HTTP or browser access to resources that would normally require authentication. The signature in the query string secures the request. Query string authentication requests require an expiration date. [...]

全部AWS Software Development Kits (SDKs)为此提供支持,这是一个使用 GetPreSignedUrlRequest Class 的示例来自 AWS SDK for .NET ,生成一个从现在起 42 分钟后过期的预签名 URL:

using (var s3Client = AWSClientFactory.CreateAmazonS3Client("AccessKey", "SecretKey"))
{
    GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
        .WithBucketName("BucketName")
        .WithKey("Key")
        .WithProtocol(Protocol.HTTP)
        .WithExpires(DateTime.Now.AddMinutes(42));

    string url = s3Client.GetPreSignedURL(request);
}

关于amazon-s3 - 如何使用 Google Cloud Storage 隐藏真实 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9733007/

相关文章:

python-3.x - 如何使用 boto3 在 2 个不同帐户的 S3 存储桶之间复制文件

android - Amazon S3 TransferUtility 在应用程序关闭时停止,即使在 WorkManager 中也是如此

ruby-on-rails-3 - 谷歌存储的存储访问凭证,用于 Rails 应用程序中的carrierwave gem

ruby-on-rails - 我是否需要在我的 Rails 应用程序中关闭与 Amazon S3 的连接?

azure - 如何备份我的 Windows Azure 表存储?

azure - CloudBlobDirectory 和在 Azure 存储中使用分隔符之间的区别?

c# - 更新[2] - ASP.NET Core Web API上传和下载文件 - Stream异常

google-app-engine - 上传至谷歌云存储

Python - 从 Google Cloud Storage 下载整个目录

python - 使用 Flask 和 Boto3 从 HTML 表单上传文件