Is there anyway to get File(image) with a regular get Http requset in elm?

Sorry if this is a noobie question but I have being looking at this for sometime now and always thought I am missing something really obvious but time has passed by and I don’t seem to understand what is it that I am missing.

I just want to make a regular request something like the following

getFromS3 : UploadCreds -> Cmd Msg
getFromS3 creds =              
    { method = "GET"           
    , headers = 
           Http.header "X-Amz-Signature" creds.credentials.signature                                                                                                                                                               
    , tracker = Nothing        
    , timeout = Nothing        
    , body = Http.emptyBody    
    !!!!!!, expect =   ?? Http.expectByte or something  with File.decoder probably ? !!!!!!
    , url = ""                                                                                                                                       

the problem is that I want to get images from the with a get method because I need credentials
I can’t just directly use the url in an img src.

is there anyway to create a custom method that would work like Http.expectFile would so I can just get the FIle ?

I think the common way of doing this is using presigned URLs:

1 Like

Most probably the appropriate solution for my case indeed. But I was wandering wether a method exist to get a file with the a request because in a different case I might want to get a pdf file for example. But I mark your response as solution because it is the solution to the particular problem in the my topic.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.