當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Bucket.Put方法代碼示例

本文整理匯總了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)
}
開發者ID:jpatel531,項目名稱:solomon-kehlua,代碼行數:9,代碼來源:kehlua.go

示例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
}
開發者ID:palaiyacw,項目名稱:imgry,代碼行數:12,代碼來源:util.go

示例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
}
開發者ID:evaluation-alex,項目名稱:gosync,代碼行數:15,代碼來源:sync_s3_s3.go

示例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
}
開發者ID:evaluation-alex,項目名稱:gosync,代碼行數:15,代碼來源:sync_dir_s3.go

示例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"
					})
開發者ID:xtreme-sameer-vohra,項目名稱:semver-resource,代碼行數:29,代碼來源:check_test.go

示例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
開發者ID:xtreme-sameer-vohra,項目名稱:semver-resource,代碼行數:31,代碼來源:out_test.go


注:本文中的github.com/mitchellh/goamz/s3.Bucket.Put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。