adminjs-upload icon indicating copy to clipboard operation
adminjs-upload copied to clipboard

Wrong path when trying to view uploaded images

Open petrakoww opened this issue 3 years ago • 5 comments

I'm uploading images successfully but when I try to view them the src in the img tag is incorrect.

image

image

It should be only http://localhost:8080/static/colors/6349c2a411aac4c21990aa54/registration/123.png What am I doing wrong and how to fix it?

petrakoww avatar Oct 14 '22 20:10 petrakoww

I found that if I edit the document's bucket to ../../../static/colors it works or kinda works.

image

But if I set the provider to local: { bucket: '../../../static/colors' } it says: Error: directory: "../../../static/colors" does not exists. Create it before running LocalAdapter

Why is /admin/resources/Test or /admin/resources/ (depending if I'm viewing the document or all) being appended to bucket + path

Also i think this issue is similar to mine. #https://github.com/SoftwareBrothers/adminjs-upload/issues/35

petrakoww avatar Oct 17 '22 13:10 petrakoww

@dziraf Do you have any idea what causes the problem?

petrakoww avatar Oct 17 '22 13:10 petrakoww

The issue is the baseUrl options parameter, which you are not using. I'm running into a similar situation. I try to run my app in a Docker container, which is not working with the standard local provider (see issue #42). Likewise, I'm currently trying to use a custom provider which is using the move method of the fs-extra package (see here https://github.com/SoftwareBrothers/adminjs-upload/issues/42#issuecomment-1130784753).

So, the only change is the move method, nothing more, all the rest is the same as the default local provider. I define the custom provider like that:

uploadFileFeature({
        provider: new UploadProvider({
          bucket: path.resolve(`./public/files`),
          opts: {
            baseUrl: '/files',
          },
        }),

As I see it, the baseUrl parameter is ignored and the component uses the bucket path, which is an absolute path and useless for the frontend. I would be happy to any feedback on how this baseUrl needs to be used with a custom provider.

ddresch avatar Feb 24 '23 22:02 ddresch

@ddresch Update your custom provider like this from line 8: image now define options like local provider

Reigin16 avatar Apr 26 '23 08:04 Reigin16