sen

sen

Elixir aws s3 response - how to get the “key” value?

I using Exaws to get my aws s3 folder directory.
response = ExAws.S3.list_objects(bucket_name, prefix: “img/pic/”,delimiter: “/”) |> ExAws.request(region: “xxxxx”)

I get the response like below. How can i get the “key” value?
Thanks.

{:ok,
 %{
   body: %{
     common_prefixes: [],
     contents: [
       %{
         e_tag: "\"d41d8ez98f00b204s9800998ecg2427e\"",
         key: "img/pic/“,
         last_modified: "2018-11-15T04:15:20.000Z",
         owner: %{
           display_name: “admin”,
           id: "e9d42292cddfe3bf5bab7f1eacfdee6b5d3a64f4528e369c6dc239a13e87c410"
         },
         size: "0",
         storage_class: "STANDARD"
       },
       %{
         e_tag: "\"e2dajb48d4qf7862d257eaf6753b3439\””,
         key: "img/pic/sample.svg",
         last_modified: "2018-11-15T04:15:40.000Z",
         owner: %{
           display_name: “admin”,
           id: "e9d42832cddfe3bf5qob7f1eacfdee6b5d3c64f4528e469c6dc339a13e23c410"
         },
         size: "1149",
         storage_class: "STANDARD"
       }
     ],
     is_truncated: "false",
     marker: "",
     max_keys: "1000",
     name: "s3-test",
     next_marker: "",
     prefix: "img/pic/“
   },
   headers: [
	……..
   ],
   status_code: 200
 }}

Marked As Solved

joaquinalcerro

joaquinalcerro

Try:

{:ok, response} = ExAws.S3.list_objects(bucket_name, prefix: “img/pic/”,delimiter: “/”) |> ExAws.request(region: “xxxxx”)

Enum.map(response.body.contents, fn( c ) → c.key end)

It should return a list with the keys.

Best regards

Last Post!

nowdev

nowdev

You can share the code ? I’m trying do the same…

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement