object

package
v0.0.0-...-5a5b885 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles object operation requests by uploading the file's data to aws-s3 Object Storage.

func NewHandler

func NewHandler(service *Service, logger *logrus.Logger) *Handler

NewHandler creates a Handler and returns it.

func (Handler) CopyObject

func (h Handler) CopyObject(
	ctx context.Context,
	request *pb.CopyObjectRequest,
) (*pb.CopyObjectResponse, error)

CopyObject - copy an object from source to destination bucket Returns the ETag of the new object. The ETag reflects only changes to the contents of an object, not its metadata. The source and destination ETag is identical for a successfully copied object.

func (Handler) DeleteObjects

func (h Handler) DeleteObjects(
	ctx context.Context,
	request *pb.DeleteObjectsRequest,
) (*pb.DeleteObjectsResponse, error)

DeleteObjects is the request handler for deleting objects. It responds with a slice of deleted object keys and a slice of failed object keys.

func (Handler) GetService

func (h Handler) GetService() *Service

GetService returns the internal upload service.

func (Handler) MoveObject

func (h Handler) MoveObject(
	ctx context.Context,
	request *pb.MoveObjectRequest,
) (*pb.MoveObjectResponse, error)

MoveObject - copy an object from source to destination bucket and delete the source

func (Handler) UploadAbort

func (h Handler) UploadAbort(
	ctx context.Context,
	request *pb.UploadAbortRequest,
) (*pb.UploadAbortResponse, error)

UploadAbort is the request handler for aborting and freeing previously uploaded parts.

func (Handler) UploadComplete

func (h Handler) UploadComplete(
	ctx context.Context,
	request *pb.UploadCompleteRequest,
) (*pb.UploadCompleteResponse, error)

UploadComplete is the request handler for completing and assembling previously uploaded file parts. Responds with the location of the assembled file.

func (Handler) UploadInit

func (h Handler) UploadInit(
	ctx context.Context,
	request *pb.UploadInitRequest,
) (*pb.UploadInitResponse, error)

UploadInit is the request handler for initiating resumable upload.

func (Handler) UploadMedia

func (h Handler) UploadMedia(
	ctx context.Context,
	request *pb.UploadMediaRequest,
) (*pb.UploadMediaResponse, error)

UploadMedia is the request handler for file upload, it is responsible for getting the file from the request's body and uploading it to the bucket of the user who uploaded it

func (Handler) UploadMultipart

func (h Handler) UploadMultipart(
	ctx context.Context,
	request *pb.UploadMultipartRequest,
) (*pb.UploadMultipartResponse, error)

UploadMultipart is the request handler for file upload, it is responsible for getting the file from the request's body and uploading it to the bucket of the user who uploaded it

func (Handler) UploadPart

func (h Handler) UploadPart(stream pb.Upload_UploadPartServer) error

UploadPart is the request handler for multipart file upload. It is fetching file parts from a RPC stream and uploads them concurrently. Responds with a stream of upload status for each part streamed.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a structure used for operations on S3 objects.

func NewService

func NewService(s3Client *s3.S3) *Service

NewService creates a Service and returns it.

func (*Service) CopyObject

func (s *Service) CopyObject(
	ctx aws.Context,
	bucketSrc *string,
	bucketDest *string,
	keySrc *string,
	keyDest *string,
) (*string, error)

CopyObject - copy an object between source and destination buckets It receives a source bucket, object key and a destination bucket

func (*Service) DeleteObjects

func (s *Service) DeleteObjects(ctx aws.Context, bucket *string, keys []*string) (*s3.DeleteObjectsOutput, error)

DeleteObjects repeated string deletes an object from s3, It receives a bucket and a slice of *strings to be deleted and returns the deleted and errored objects or an error if exists.

func (*Service) GetS3Client

func (s *Service) GetS3Client() *s3.S3

GetS3Client returns the internal s3 client.

func (*Service) HeadObject

func (s *Service) HeadObject(ctx aws.Context, key *string, bucket *string) (*s3.HeadObjectOutput, error)

HeadObject returns object's details.

func (*Service) ListUploadParts

func (s *Service) ListUploadParts(
	ctx aws.Context,
	uploadID *string,
	key *string,
	bucket *string,
) (*s3.ListPartsOutput, error)

ListUploadParts lists the uploaded file parts of a multipart upload of a file.

func (*Service) UploadAbort

func (s *Service) UploadAbort(ctx aws.Context, uploadID *string, key *string, bucket *string) (bool, error)

UploadAbort aborts a multipart upload. After a multipart upload is aborted, no additional parts can be uploaded using that upload ID. The storage consumed by any previously uploaded parts will be freed. However, if any part uploads are currently in progress, those part uploads might or might not succeed. As a result, it might be necessary to abort a given multipart upload multiple times in order to completely free all storage consumed by all parts. To verify that all parts have been removed, so you don't get charged for the part storage, you should call the List Parts operation and ensure the parts list is empty.

func (*Service) UploadComplete

func (s *Service) UploadComplete(
	ctx aws.Context,
	uploadID *string,
	key *string,
	bucket *string,
) (*s3.CompleteMultipartUploadOutput, error)

UploadComplete completes a multipart upload by assembling previously uploaded parts associated with uploadID.

func (*Service) UploadFile

func (s *Service) UploadFile(
	ctx aws.Context,
	file io.Reader,
	key *string,
	bucket *string,
	contentType *string,
	metadata map[string]*string,
) (*string, error)

UploadFile uploads a file to the given bucket and key in S3. If metadata is a non-nil map then it will be uploaded with the file. Returns the file's location and an error if any occurred.

func (*Service) UploadInit

func (s *Service) UploadInit(
	ctx aws.Context,
	key *string,
	bucket *string,
	contentType *string,
	metadata map[string]*string,
) (*s3.CreateMultipartUploadOutput, error)

UploadInit initiates a multipart upload to the given bucket and key in S3 with metadata. File metadata is required for multipart upload.

func (*Service) UploadPart

func (s *Service) UploadPart(
	ctx aws.Context,
	uploadID *string,
	key *string,
	bucket *string,
	partNumber *int64,
	body io.ReadSeeker,
) (*s3.UploadPartOutput, error)

UploadPart uploads a part in a multipart upload of a file.

Jump to

Keyboard shortcuts

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