本文整理匯總了Golang中github.com/mitchellh/goamz/s3.Bucket.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bucket.Get方法的具體用法?Golang Bucket.Get怎麽用?Golang Bucket.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mitchellh/goamz/s3.Bucket
的用法示例。
在下文中一共展示了Bucket.Get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: writeS3FileToPath
func writeS3FileToPath(file string, bucket *s3.Bucket, path string) error {
data, err := bucket.Get(path)
if err != nil {
return err
}
perms := os.FileMode(0644)
err = ioutil.WriteFile(file, data, perms)
if err != nil {
return err
}
return nil
}
示例2: writeS3FileToS3
func writeS3FileToS3(sourceBucket, targetBucket *s3.Bucket, sourceKeyPath, targetKeyPath string) error {
data, err := sourceBucket.Get(sourceKeyPath)
if err != nil {
return err
}
contType := mime.TypeByExtension(filepath.Ext(sourceKeyPath))
Perms := s3.ACL("private")
if err := targetBucket.Put(targetKeyPath, data, contType, Perms); err != nil {
return err
}
return nil
}
示例3:
BeforeEach(func() {
request.Params.File = "number"
})
Context("when a valid version is in the file", func() {
BeforeEach(func() {
err := ioutil.WriteFile(filepath.Join(source, "number"), []byte("1.2.3"), 0644)
Ω(err).ShouldNot(HaveOccurred())
})
It("reports the version as the resource's version", func() {
Ω(response.Version.Number).Should(Equal("1.2.3"))
})
It("saves the contents of the file in the configured bucket", func() {
contents, err := bucket.Get(key)
Ω(err).ShouldNot(HaveOccurred())
Ω(string(contents)).Should(Equal("1.2.3"))
})
})
})
Context("when bumping the version", func() {
BeforeEach(func() {
err := bucket.Put(key, []byte("1.2.3"), "text/plain", s3.Private)
Ω(err).ShouldNot(HaveOccurred())
})
for bump, result := range map[string]string{
"final": "1.2.3",