scenarios

package
v0.0.0-...-ba09527 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunGetStartedScenario

func RunGetStartedScenario(sdkConfig aws.Config, questioner demotools.IQuestioner)

RunGetStartedScenario is an interactive example that shows you how to use Amazon Simple Storage Service (Amazon S3) to create an S3 bucket and use it to store objects.

1. Create a bucket. 2. Upload a local file to the bucket. 3. Upload a large object to the bucket by using an upload manager. 4. Download an object to a local file. 5. Download a large object by using a download manager. 6. Copy an object to a different folder in the bucket. 7. List objects in the bucket. 8. Delete all objects in the bucket. 9. Delete the bucket.

This example creates an Amazon S3 service client from the specified sdkConfig so that you can replace it with a mocked or stubbed config for unit testing.

It uses a questioner from the `demotools` package to get input during the example. This package can be found in the ..\..\demotools folder of this repo.

func RunPresigningScenario

func RunPresigningScenario(sdkConfig aws.Config, questioner demotools.IQuestioner, httpRequester IHttpRequester)

RunPresigningScenario is an interactive example that shows you how to get presigned HTTP requests that you can use to move data into and out of Amazon Simple Storage Service (Amazon S3). The presigned requests contain temporary credentials and can be used by an HTTP client.

1. Get a presigned request to put an object in a bucket. 2. Use the net/http package to use the presigned request to upload a local file to the bucket. 3. Get a presigned request to get an object from a bucket. 4. Use the net/http package to use the presigned request to download the object to a local file. 5. Get a presigned request to delete an object from a bucket. 6. Use the net/http package to use the presigned request to delete the object.

This example creates an Amazon S3 presign client from the specified sdkConfig so that you can replace it with a mocked or stubbed config for unit testing.

It uses a questioner from the `demotools` package to get input during the example. This package can be found in the ..\..\demotools folder of this repo.

It uses an IHttpRequester interface to abstract HTTP requests so they can be mocked during testing.

Types

type HttpRequester

type HttpRequester struct{}

HttpRequester uses the net/http package to make HTTP requests during the scenario.

func (HttpRequester) Delete

func (httpReq HttpRequester) Delete(url string) (resp *http.Response, err error)

func (HttpRequester) Get

func (httpReq HttpRequester) Get(url string) (resp *http.Response, err error)

func (HttpRequester) Put

func (httpReq HttpRequester) Put(url string, contentLength int64, body io.Reader) (resp *http.Response, err error)

type IHttpRequester

type IHttpRequester interface {
	Get(url string) (resp *http.Response, err error)
	Put(url string, contentLength int64, body io.Reader) (resp *http.Response, err error)
	Delete(url string) (resp *http.Response, err error)
}

IHttpRequester abstracts HTTP requests into an interface so it can be mocked during unit testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL