func Test_S3Upload(t *testing.T) {
	b := []byte(`{"events":[
     {
        "event":"processed"
     },
     {
        "event":"deferred"
     }
  ], "account": "foo"}`)
	err := s3.Upload(b, "foo")
	assert.NoError(t, err, "file should be uploaded to s3")
}
示例#2
0
func main() {
	apex.HandleFunc(func(event json.RawMessage, ctx *apex.Context) (interface{}, error) {
		log.Println(string(event))
		var params proxy.Params
		if err := json.Unmarshal(event, &params); err != nil {
			return nil, err
		}
		if err := proxy.Process(event, params.Body); err != nil {
			return nil, err
		}
		if err := s3.Upload(event, params.Account); err != nil {
			return nil, err
		}
		return nil, errors.New("Upload to S3 - OK. Proxy Request - OK")
	})

}