本文整理匯總了Golang中github.com/mitchellh/goamz/s3.Bucket.Put方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bucket.Put方法的具體用法?Golang Bucket.Put怎麽用?Golang Bucket.Put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mitchellh/goamz/s3.Bucket
的用法示例。
在下文中一共展示了Bucket.Put方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: upload
func upload(_file file, uploads chan<- bool, client *s3.S3, bucket *s3.Bucket) {
err := bucket.Put(_file.path, _file.data, _file.contentType, permissions)
if err != nil {
fmt.Printf("UPLOAD ERROR: %+v\n", err)
panic(err)
}
uploads <- true
fmt.Printf("Uploaded %s!\n", _file.path)
}
示例2: s3Upload
func s3Upload(bucket *s3.Bucket, path string, im *Image) (string, error) {
var url string
if len(im.Data) == 0 {
return "", fmt.Errorf("No image data found for %s", path)
}
err := bucket.Put(path, im.Data, im.MimeType(), s3.PublicRead)
if err != nil {
return url, err
}
url = bucket.URL(path)
return url, nil
}
示例3: 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
}
示例4: writeLocalFileToS3
func writeLocalFileToS3(bucket *s3.Bucket, path string, file string) error {
contType := mime.TypeByExtension(filepath.Ext(file))
Perms := s3.ACL("private")
data, err := ioutil.ReadFile(file)
if err != nil {
return err
}
if err := bucket.Put(path, data, contType, Perms); err != nil {
return err
}
return nil
}
示例5:
// account for roundtrip to s3
Eventually(session, 5*time.Second).Should(gexec.Exit(0))
err = json.Unmarshal(session.Out.Contents(), &response)
Ω(err).ShouldNot(HaveOccurred())
})
Context("with no version", func() {
BeforeEach(func() {
request.Version.Number = ""
})
Context("when a version is present in the source", func() {
BeforeEach(func() {
err := bucket.Put(key, []byte("1.2.3"), "text/plain", "")
Ω(err).ShouldNot(HaveOccurred())
})
It("returns the version present at the source", func() {
Ω(response).Should(HaveLen(1))
Ω(response[0].Number).Should(Equal("1.2.3"))
})
})
Context("when no version is present at the source", func() {
Context("and an initial version is set", func() {
BeforeEach(func() {
request.Source.InitialVersion = "10.9.8"
})
示例6:
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",
"patch": "1.2.4",
"minor": "1.3.0",
"major": "2.0.0",
} {
bumpLocal := bump
resultLocal := result
Context(fmt.Sprintf("when bumping %s", bumpLocal), func() {
BeforeEach(func() {
request.Params.Bump = bumpLocal