Skip to content

Commit

Permalink
support output of raw content to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
fogfish committed Oct 31, 2020
1 parent 4000c97 commit 0278bdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ type Gen interface {
// Blob is a generic byte stream trait to access large binary data
type Blob interface {
Recv(curie.Thing) (io.ReadCloser, error)
Send(curie.Thing, io.Reader) error
}

//
Expand Down
16 changes: 15 additions & 1 deletion s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3iface"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/fogfish/curie"
)

Expand Down Expand Up @@ -216,7 +217,7 @@ func (dynamo S3) Match(key curie.Thing) Seq {
//
//-----------------------------------------------------------------------------

// Recv establishes bytes stream to S3 object
// Recv establishes ingress bytes stream to S3 object
func (dynamo S3) Recv(entity curie.Thing) (io.ReadCloser, error) {
req := &s3.GetObjectInput{
Bucket: dynamo.bucket,
Expand Down Expand Up @@ -253,3 +254,16 @@ func (dynamo S3) Recv(entity curie.Thing) (io.ReadCloser, error) {

return in.Body, nil
}

// Send establishes egress bytes stream to S3 object
func (dynamo S3) Send(entity curie.Thing, stream io.Reader) error {
up := s3manager.NewUploader(dynamo.io)

_, err := up.Upload(&s3manager.UploadInput{
Bucket: dynamo.bucket,
Key: aws.String(entity.Identity().Path()),
Body: stream,
})

return err
}

0 comments on commit 0278bdf

Please sign in to comment.