Show and download image from fileserver


#1

Hey,

i had uploaded some images withe the rest api on the file server. The files are stored on my own server under /opt/df2/storage/app/upload/12.

For my project i want to show an image inside the folder. If i’m just using the link from the rest api inside an i have no permission.
The other thing is when i request the picture with the rest api i get a lot of cryptic code (binary?) how can i display it as image again?

I am using DF2 and Javascript with angularjs. The server is an apache server.

Hope you can help me, thanks.


#2

@Steffen_Hollenbach if you put the path to the file in the browser on the server does it render correctly in the browser? The image may require some encoding/decoding to be displayed correctly to the end user.


#3

Hi Steffen,

I might be able to help on that.
For the first issue, you should set the folder 12 as public, that should fix the access issue. In may case, in the service definition, I have set the folders m6u, m6q, m6c as public. everything inside is visible directly in the browser.

For the second issue, I think that the images are not correctly uploaded from angular.
I had some issues too. now I’m using ng-file-upload (https://github.com/danialfarid/ng-file-upload) and it works like a charm. This is the method to upload an image:

data.uploadImage = function (blob, uploadUrl, fileName) {

    Upload.http({
        url: uploadUrl,
        headers : {
            "Content-Type": "image/png",
            "X-File-Name": fileName
        },
        processData: false,
        data: blob

    }).then(function (resp) {
        //$rootScope.$broadcast('camera.upload');
    }, function (resp) {
        //$rootScope.$broadcast('camera.upload');
    }, function (evt) {
        var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
        console.log('progress: ' + progressPercentage + '% ');
    });
} 

I hope this helps
Gabriel


#4

Here even if I put the folder in the public paths array it’s not working. I can’t access this public folder and files.


#5

Hi @bitperbit,

I am trying to use ng-file-upload, but I am currently getting a 500 error. IS there anyway you could share some more you your code with me?

Thanks,

Brock