Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wrap ¶
Wrap returns an io.Reader that reads from the wrapped io.Reader and implements the Tagger interaface.
If content implements Tagger then the returned Reader returns ETag of the content. Otherwise, it returns nil as ETag.
Wrap provides an adapter for io.Reader implemetations that don't implement the Tagger interface. It is mainly used to provide a high-level io.Reader access to the ETag computed by a low-level io.Reader:
content := etag.NewReader(r.Body, nil) compressedContent := Compress(content) encryptedContent := Encrypt(compressedContent) // Now, we need an io.Reader that can access // the ETag computed over the content. reader := etag.Wrap(encryptedContent, content)
Types ¶
type ETag ¶
type ETag []byte
ETag is a single S3 ETag.
An S3 ETag sometimes corresponds to the MD5 of the S3 object content. However, when an object is encrypted, compressed or uploaded using the S3 multipart API then its ETag is not necessarily the MD5 of the object content.
For a more detailed description of S3 ETags take a look at the package documentation.
func FromContentMD5 ¶
FromContentMD5 decodes and returns the Content-MD5 as ETag, if set. If no Content-MD5 header is set it returns an empty ETag and no error.
func Multipart ¶
Multipart computes an S3 multipart ETag given a list of S3 singlepart ETags. It returns nil if the list of ETags is empty.
Any encrypted or multipart ETag will be ignored and not used to compute the returned ETag.
func Parse ¶
Parse parses s as an S3 ETag, returning the result. The string can be an encrypted, singlepart or multipart S3 ETag. It returns an error if s is not a valid textual representation of an ETag.
func (ETag) ETag ¶
ETag returns the ETag itself.
By providing this method ETag implements the Tagger interface.
func (ETag) IsEncrypted ¶
IsEncrypted reports whether the ETag is encrypted.
func (ETag) IsMultipart ¶
IsMultipart reports whether the ETag belongs to an object that has been uploaded using the S3 multipart API. An S3 multipart ETag has a -<part-number> suffix.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
A Reader wraps an io.Reader and computes the MD5 checksum of the read content as ETag.
Optionally, a Reader can also verify that the computed ETag matches an expected value. Therefore, it compares both ETags once the underlying io.Reader returns io.EOF. If the computed ETag does not match the expected ETag then Read returns a VerifyError.
Reader implements the Tagger interface.
func NewReader ¶
NewReader returns a new Reader that computes the MD5 checksum of the content read from r as ETag.
If the provided etag is not nil the returned Reader compares the etag with the computed MD5 sum once the r returns io.EOF.
type Tagger ¶
type Tagger interface {
ETag() ETag
}
Tagger is the interface that wraps the basic ETag method.
type VerifyError ¶
VerifyError is an error signaling that a computed ETag does not match an expected ETag.
func (VerifyError) Error ¶
func (v VerifyError) Error() string