danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.59k forks source link

How to load images previously saved, now loaded from a remote endpoint #2064

Open theCrius opened 6 years ago

theCrius commented 6 years ago

Using the basic example for uploading images I managed to upload an image.

Now I would like to be able to display the image uploaded once someone go back to edit the page that contains the ng-file-upload directive.

The backend (on which I don't have direct control but could ask modifications) return to me an image, this is an example of the request/response:

[REQUEST]
GET /xxxxxx/v1/contacts/54041/images/e739beeea641ca585a49d4b19e64d8da.jpeg HTTP/1.1
Host: xxxxxx.xxxxxxxxx.com
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: application/json, text/plain, */*
Origin: http://localhost
Authorization: $2y$10$N7oK1Sp9drdtjfpKwM6k1uiMWI7SKeJpFMd7dhSG9BrQTe8/rfSLC
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Referer: http://localhost/xxxxxx/app/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8

[RESPONSE]
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 7044
Content-Type: image/jpeg
Vary: Origin
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: http://localhost
X-Powered-By: PHP/7.1.10
Date: Fri, 13 Apr 2018 13:11:31 GMT

And of course the response itself that is an image/jpg. How can I add this image to the model so that the ngf-thumbnail can display it?