JPro-one / JPro

The right place to report about bugs or suggest improvements for JPro.
https://www.jpro.one
9 stars 4 forks source link

WebApi.createVirtualImage - Direct access for presigned URL #164

Closed guirak closed 11 months ago

guirak commented 1 year ago

Hi Florian,

I am using the WebAPI to create a virtual image from an image stored in AWS S3. I'm using a presigned URL to make accessible the image :

https://[...].s3.eu-west-3.amazonaws.com/[...]/avocats.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20231022T120530Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86399&X-Amz-Credential=AKIA3OIKLT4FAUTUTSGJ%2F20231022%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Signature=92365e8fc4df05b169f32d623152bf4da4d198180845eaae50cd3b58a60fddda

When using the method : public static Image createVirtualImage(String url, int w, int h), this is working perfectly.

To reduce the workload of my JPRO server and permit the browser to load directly the image, I tried to use the method createVirtualImage(String url, int w, int h, boolean jproServerAsProxy) providing false in jproServerAsProxy. In this case it is not working, I have the following error : [WARN ] c.jpro - resource not available: java.io.IOException: Server returned HTTP response code: 403 for URL: https://[...].s3.eu-west-3.amazonaws.com/[...]/avocats.png

I have tested passing true to jproServerAsProxy and I have the same problem.

It seems the request parameters are not taken into account by the second method while it's working with the first one.

Regards,

FlorianKirmaier commented 11 months ago

Is there a way to test this? Could you provide a small snippet with an image that does not work? Then it's easy to fix.

guirak commented 11 months ago

Hi Florian,

You can use this repo to reproduce the issue : https://github.com/guirak/JProIssue164

Just clone the repo and launch JPRO. A warning is present for methods that doesn't work :

[WARN ] c.jpro - resource not available: java.io.IOException: Server returned HTTP response code: 403 for URL: https://mmione-tests.s3.eu-west-3.amazonaws.com/global/mmi_order/rayons/jus.jpg

The presigned URL is valid only for 24h. I can't configure a presigned URL with bigger duration.

Thank you.

FlorianKirmaier commented 11 months ago

Thank you. Then We'll only have 24 hours to fix it, so we must be fast. :D

FlorianKirmaier commented 11 months ago

The default behavior (which doesn't use JPro as a proxy) is what you want. You get it currently when not providing the boolean parameter.

It looks like, currently, the boolean parameter is ignored, when provided. So we are fixing that.

FlorianKirmaier commented 11 months ago

Thank you very much for the test application! Sadly the link already is expired. Can you create a new link for a final test? We are at the end of fixing that.

FlorianKirmaier commented 11 months ago

@guirak Checkout the version 2023.3.4-SNAPSHOT It should fix it. But probably the default behavior, without an argument, is what you want.