Amazonka: How to generate S3:// uri from Network.AWS.S3.Types.Object?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Amazonka: How to generate S3:// uri from Network.AWS.S3.Types.Object?

Cody Goodman

Question: How can I generate an S3://absolute/url from an Object (https://hackage.haskell.org/package/amazonka-s3-1.4.5/docs/Network-AWS-S3-Types.html#t:Object)?

Context: I've been using turtle to call "aws s3 ls" and I'm trying to figure out how to replace that with amazonka. Absolute s3 urls were central to how my program worked. I KNow how to get objects now and filter them, but I don't know how to convert an object to an S3 url to integrate with my existing program.


Perhaps I had something wrong, but it didn't seem like just the S3 Bucket and S3 Object key were enough to download a given file. If I'm wrong about that I need to double check my configuration.

Thanks,

Cody Goodman


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Amazonka: How to generate S3:// uri from Network.AWS.S3.Types.Object?

Mark Fine
The getFile example downloads and object from S3 and "sinks" its contents to a file. To integrate with an existing program that's using S3 URIs, you can build it with the bucket and key:

s3Uri :: BucketName -> ObjectKey -> Text
s3Uri (BucketName bn) (ObjectKey ok) = "s3://" <> bn <> "/" <> ok

There are also presigned S3 URLs (also in the examples file), but those are for HTTP requests, not aws cli requests.

Using turtle with with aws cli is great - nice light way to get AWS functionality without going pulling in amazonka.

Mark

On Tue, Oct 31, 2017 at 11:43 PM, Cody Goodman <[hidden email]> wrote:

Question: How can I generate an S3://absolute/url from an Object (https://hackage.haskell.org/package/amazonka-s3-1.4.5/docs/Network-AWS-S3-Types.html#t:Object)?

Context: I've been using turtle to call "aws s3 ls" and I'm trying to figure out how to replace that with amazonka. Absolute s3 urls were central to how my program worked. I KNow how to get objects now and filter them, but I don't know how to convert an object to an S3 url to integrate with my existing program.


Perhaps I had something wrong, but it didn't seem like just the S3 Bucket and S3 Object key were enough to download a given file. If I'm wrong about that I need to double check my configuration.

Thanks,

Cody Goodman


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.