89
Views
14
Comments
Solved
[File Viewer Plugin] JPEG not opening
Question
file-viewer-plugin
Mobile icon
Forge asset by OutSystems

While using the file viewer plugin, after saving a jpeg image to the local storage using the file plugin's action "Save File", the image is not displayed and, although there is an error, there is no error message or error code returned...

2019-01-23 10-11-10
Carlos Almeida
Solution

So... apparently removing the component and re-downloading it from the forge seems to have worked. Something freaky might have happened...

2018-06-19 09-34-03
flpmorais

How are you displaying the image? How are you using the plugin? Can you provide the oml/screenshots? Service center log? Do you have content security policies in place? What do you have under img-src on the CSP?

It's hard to figure much without more context.



2019-01-23 10-11-10
Carlos Almeida

I'm generating an image binary from a webpage. The image is generated correctly, since I can display it on a screen. After that, using the SaveFile action, I save it to the local storage:


After that, I'm trying to open the image using the File Viewer plugin, using the URI provided by the SaveFile Action:



After that call to the OpenDocument action, the action returns Success = false and no error message:


There is nothing available on the Service Center logs and I have 0 clue what you mean with "What do you have under img-src on the CSP?". 


Also, before we were converting the image to pdf and opening the pdf with the File Viewer and it was working properly, but the client requested that the file be opened as an image and we haven't been able to.

2018-06-19 09-34-03
flpmorais

Wait, why are you opening the image with the File Viwer? Why not use directly the image widget?

CSP is the content security policy:

2019-01-23 10-11-10
Carlos Almeida

flpmorais wrote:

Wait, why are you opening the image with the File Viwer? Why not use directly the image widget?

Because I want to open the image, not display it on the app. Using the image widget, I can display it on the app (that's how I know that the image is being properly generated and is not corrupted) but that is not the objective here.

My CSP looks like this:



2018-06-19 09-34-03
flpmorais

On SaveFile change the typeId to external. You won't be able to open images internal to your app with the external app (i.e. gallery). I also used image/* as the mimetype, but I think it was the "external image" that made it work.

I've made and attached a small working example of what you are trying to achieve.

Remember to mark the answer as solution if it solved your problem ;)

asd.oml
2018-06-19 09-34-03
flpmorais

Oh... And do use content security policies. Your app is basically vulnerable to a lot of stuff if you don't.

2019-01-23 10-11-10
Carlos Almeida

Thanks for the help, I'll try that in a bit. Also, it is just a POC at the time, I'm sure the DM is planning on adding the CSPs when this gets greenlit :)

2019-01-23 10-11-10
Carlos Almeida

Unfortunately, it didn't solve my problem. I even tried it with a static image (ignoring the one generated by the app) from my resources and still it wouldn't work, with internal or external. 

2018-06-19 09-34-03
flpmorais

Are you using Outsystems Now? Have you taken a look at my OML?Have you tried to change the mimetype to "image/*"?

The OML I provided here is just take picture -> save file -> openDocument and it is working, so maybe you can solve your problem by comparing it to my code?

2019-01-23 10-11-10
Carlos Almeida

flpmorais wrote:

Are you using Outsystems Now? Have you taken a look at my OML?Have you tried to change the mimetype to "image/*"?

The OML I provided here is just take picture -> save file -> openDocument and it is working, so maybe you can solve your problem by comparing it to my code?

I didn't notice this post, I'm sorry.


I'm not using outsystems now, I'm installing the app on my android. I did change the mimetype to image/* but still to no avail. My code is basically the same as yours, without the picture taking...


2019-01-23 10-11-10
Carlos Almeida

Also, I noticed your oml was in version 11, I'm still using OS version 10. Does the plugin has any know issues in version 10?

2018-06-19 09-34-03
flpmorais

Not that I'm aware of. Yes I'm on 11 but the version of the plugin I'm using is from 10. So it should work.

2019-01-23 10-11-10
Carlos Almeida
Solution

So... apparently removing the component and re-downloading it from the forge seems to have worked. Something freaky might have happened...

2018-06-19 09-34-03
flpmorais

Nice and thanks for letting me know!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.