Created
November 11, 2021 14:12
-
-
Save joshuarobinson/e74ab2268cae9c5db692d78bdefff0ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AWS-CLI example to add custom-metadata to an existing object using the zero-copy API | |
aws --endpoint-url $ENDPOINT s3api copy-object --bucket $BUCKET --copy-source $BUCKET/$KEY --key $KEY --metadata '{"custom-thing":"123456"}' --metadata-directive REPLACE | |
# Golang code to get the contents of an object, very similar to Boto3 | |
input := &s3.GetObjectInput{Bucket: bucketname, Key: &k} | |
result, err := input_svc.GetObject(input) | |
# Boto3 reference for CopyObject, which is a zero-copy operation on FlashBlade | |
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.copy_object | |
# Golang code that puts object and adds key to Kafka topic to alert downstream consumers | |
put_cfg := &s3.PutObjectInput{ | |
Body: bytes.NewReader(val_blob), | |
Bucket: &offloadBucket, | |
Key: key, | |
} | |
_, err := offload_svc.PutObject(put_cfg) | |
reportAWSError(err) | |
path := "s3://" + offloadBucket + "/" + *key | |
val_blob = []byte(path) | |
if stagingTopic != "" { | |
_ = kafkaProducer.Produce(&kafka.Message{ | |
TopicPartition: kafka.TopicPartition{Topic: &stagingTopic, Partition: kafka.PartitionAny}, | |
Value: val_blob, | |
}, delivery_chan) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment