예제 #1
0
파일: abs.go 프로젝트: wunderlist/hamustro
// Send a single Event into the Azure Queue Storage.
func (c *BlobStorage) Save(msg *bytes.Buffer) error {
	buffer, err := dialects.Compress(msg)
	if err != nil {
		return err
	}
	if err := c.Client.CreateBlockBlobFromReader(c.Container, dialects.GetRandomPath(c.BlobPath, c.FileFormat),
		uint64(buffer.Len()), bytes.NewReader(buffer.Bytes()), nil); err != nil {
		return err
	}
	return nil
}
예제 #2
0
파일: s3.go 프로젝트: wunderlist/hamustro
// Publish a single Event to SNS topic.
func (c *S3Storage) Save(msg *bytes.Buffer) error {
	buffer, err := dialects.Compress(msg)
	if err != nil {
		return err
	}
	fileSize := buffer.Len()
	fileBytes := buffer.Bytes()
	params := &s3.PutObjectInput{
		Bucket:        &c.Bucket,
		Key:           aws.String(dialects.GetRandomPath(c.BlobPath, c.FileFormat)),
		Body:          bytes.NewReader(fileBytes),
		ContentLength: aws.Int64(int64(fileSize)),
		ContentType:   aws.String(http.DetectContentType(fileBytes)),
		Metadata:      map[string]*string{"Key": aws.String("MetadataValue")}}
	_, err = c.Client.PutObject(params)
	if err != nil {
		return err
	}
	return nil
}