本文整理匯總了Golang中launchpad/net/goamz/s3.Bucket.Put方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bucket.Put方法的具體用法?Golang Bucket.Put怎麽用?Golang Bucket.Put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類launchpad/net/goamz/s3.Bucket
的用法示例。
在下文中一共展示了Bucket.Put方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: generateThumbnails
func generateThumbnails(file multipart.File, userId, pathPrefix string, bucket *s3.Bucket) error {
file.Seek(0, 0)
img, _, err := image.Decode(file)
if err != nil {
log.Println("Error decoding image", err)
return err
}
var buf bytes.Buffer
for _, i := range THUMBNAIL_SIZES {
resized := resize.Resize(uint(i), 0, img, resize.Lanczos3)
err = jpeg.Encode(&buf, resized, nil)
if err != nil {
return err
}
path := fmt.Sprintf("%s/%d.jpg", pathPrefix, i)
err = bucket.Put(path, buf.Bytes(), "image/jpeg", s3.PublicRead)
if err != nil {
return err
}
buf.Reset()
}
return err
}
示例2: upload
func upload(directory string, f os.FileInfo, bucket *s3.Bucket, permission s3.ACL) {
log.Println("uploading " + f.Name())
data, err := ioutil.ReadFile(path.Join(directory, f.Name()))
if err != nil {
panic(err.Error())
}
err = bucket.Put(f.Name(), data, "", permission)
if err != nil {
panic(err.Error())
}
log.Println("finished uploading " + f.Name())
}
示例3: Put
func Put(bucket *s3.Bucket, path string, file string) {
contType := "binary/octet-stream"
Perms := s3.ACL("private")
data, err := ioutil.ReadFile(file)
if err != nil {
panic(err.Error())
}
err = bucket.Put(path, data, contType, Perms)
if err != nil {
panic(err.Error())
}
}