Trying to learn to use ExAws

I’m following an example from dockyard but I’m trying to modify it to my needs.

First of all I’m not working with context of a base64 image. I already have uploaded my image to my server and have mutated it via Mogrify and it is local and available to my elixir app.

I assume in their example of AssetStore when they try to decode the image via

  # Decode the image
    {:ok, image_binary} = Base.decode64(image_base64)

I would in place of this use File.read? If so is that not loading the image into memory? Is there not a more efficient way to send the file to S3 without loading the image into memory?

I assume image_binary could possibly be a path or a stream?

 # Upload to S3
    {:ok, response} = 
      S3.put_object(image_bucket, filename, image_binary)
      |> ExAws.request()

I think I may have found my own solution.
https://hexdocs.pm/ex_aws_s3/ExAws.S3.html#module-higher-level-operations

3 Likes