英文:
Generate Torrent from Bucket via Go SDK (Amazon S3)
问题
我正在尝试找出一种使用AWS SDK for Go从存储桶生成种子文件的方法。
我正在使用预签名URL(因为这是一个私有存储桶):
svc := s3.New(session.New(config))
req, _ := svc.GetObjectRequest(&s3.GetObjectInput{
Bucket: aws.String("bucketName"),
Key: "key",
})
// 签署URL
url, err := req.Presign(120 * time.Minute)
根据文档,要生成种子文件,语法如下:
GET /ObjectName?torrent HTTP/1.1
Host: BucketName.s3.amazonaws.com
Date: date
Authorization: authorization string
在Go中,如何将 ?torrent
参数添加到预签名URL中?
英文:
I'm trying to figure out a way to generate torrent files from a bucket, using the AWS SDK for Go.
I'm using a pre-signed url (since its a private bucket):
svc := s3.New(session.New(config))
req, _ := svc.GetObjectRequest(&s3.GetObjectInput{
Bucket: aws.String("bucketName"),
Key: "key",
})
// sign the url
url, err := req.Presign(120 * time.Minute)
From the docs, to generate a torrent, the syntax:
GET /ObjectName?torrent HTTP/1.1
Host: BucketName.s3.amazonaws.com
Date: date
Authorization: authorization string
How do I add the ?torrent
parameter to a presigned url in GO?
答案1
得分: 1
尝试使用AWS Go SDK中的GetOBjectTorrent
方法。它会在响应中返回一个.torrent
文件,以下是示例代码:
svc := s3.New(session.New())
input := &s3.GetObjectTorrentInput{
Bucket: aws.String("bucketName"),
Key: aws.String("key"),
}
result, _ := svc.GetObjectTorrent(input)
fmt.Println(result)
请参阅http://docs.aws.amazon.com/sdk-for-go/api/service/s3/#S3.GetObjectTorrent了解更多详细信息。希望能对你有所帮助。
英文:
Try GetOBjectTorrent
method on the AWS Go SDK. It will return you .torrent
file in response, here is example code:
svc := s3.New(session.New())
input := &s3.GetObjectTorrentInput{
Bucket: aws.String("bucketName"),
Key: aws.String("key"),
}
result, _ := svc.GetObjectTorrent(input)
fmt.Println(result)
Please see http://docs.aws.amazon.com/sdk-for-go/api/service/s3/#S3.GetObjectTorrent for more details. Hope it helps.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论