Last active
September 8, 2016 03:56
-
-
Save jeisenberg/a0a5a7b8832cf56f3556e98256c51b55 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def update(conn, %{"id" => id, "uploaded_image" => uploaded_image}) do | |
contents = uploaded_image.path | |
|> File.read!() | |
response = S3.put_object(System.get_env("AWS_BUCKET"), uploaded_image.filename, contents) | |
|> ExAws.request!() | |
case response do | |
%{status_code: 200} -> | |
# do something here after s3 uploads successfully | |
_ -> | |
# catch everything else as a wildcard and have them try again | |
conn | |
|> put_flash(:error, "Error uploading file") | |
|> redirect(to: "/admin/resource/"<>id<>"/edit?type=image") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment