Telefonica / webview-bridge

Novum JavaScript Bridge
MIT License
27 stars 7 forks source link

SHARE_BASE64 New method to share files in base64 #138

Closed dagonco closed 4 months ago

dagonco commented 5 months ago

Due to the new requirement to be able to generate invoices and that they can be shared or downloaded by the user. It is necessary to create a new bridge method since these invoices cannot be hosted anywhere. These files could be of any type (pdfs or zips).

Documentation:

ShareBase64

shareBase64: ({ content: string, fileName: string }) => Promise<void>
Request → { type: "SHARE_BASE64", id: string, payload: { content: "base64 string", fileName: "fileName.ext" } } 
Response → { type: "SHARE_BASE64", id: string }

Success response

Empty response.

Error response codes

400 → Bad request: If payload is null or there's any missing mandatory parameter. 500 → Internal Error: If an error occurred while processing the file

Discarded ideas

amegias commented 5 months ago

I would improve the example:

- Request → { type: "SHARE_BASE64", id: string, payload: { content: "base64 string", fileName?: "pdfname" } } 
+ Request → { type: "SHARE_BASE64", id: string, payload: { content: "base64 string", fileName: "pdfname.pdf" } } 
Response → { type: "SHARE_BASE64", id: string }

I guess the extension will come in the fileName right? In addition, can fileName be null? I would force it as mandatory, wdyt?

dagonco commented 5 months ago

I left it optional because for the SHARE method this filename field does not exist, and we are the ones who put "Document" as the file prefix, same with the extension.

But I dont have a strong opinion to let it mandatory and let web to put the extension, I just wanted to reuse all SHARE logic possible.

alejandroruizponce commented 5 months ago

I would improve the example:

- Request → { type: "SHARE_BASE64", id: string, payload: { content: "base64 string", fileName?: "pdfname" } } 
+ Request → { type: "SHARE_BASE64", id: string, payload: { content: "base64 string", fileName: "pdfname.pdf" } } 
Response → { type: "SHARE_BASE64", id: string }

I guess the extension will come in the fileName right? In addition, can fileName be null? I would force it as mandatory, wdyt?

I left it optional because for the SHARE method this filename field does not exist, and we are the ones who put "Document" as the file prefix, same with the extension.

But I dont have a strong opinion to let it mandatory and let web to put the extension, I just wanted to reuse all SHARE logic possible.

I don't see the point in making this parameter optional. It implies that at the time of showing the modal Share if the filename is null we have to define a name for the file that we are going to share. I believe that this responsibility should come to us made from webapp and always receive a name with which we want to share the file.

dpastor commented 5 months ago

I would improve the example:

- Request → { type: "SHARE_BASE64", id: string, payload: { content: "base64 string", fileName?: "pdfname" } } 
+ Request → { type: "SHARE_BASE64", id: string, payload: { content: "base64 string", fileName: "pdfname.pdf" } } 
Response → { type: "SHARE_BASE64", id: string }

I guess the extension will come in the fileName right? In addition, can fileName be null? I would force it as mandatory, wdyt?

I left it optional because for the SHARE method this filename field does not exist, and we are the ones who put "Document" as the file prefix, same with the extension. But I dont have a strong opinion to let it mandatory and let web to put the extension, I just wanted to reuse all SHARE logic possible.

I don't see the point in making this parameter optional. It implies that at the time of showing the modal Share if the filename is null we have to define a name for the file that we are going to share. I believe that this responsibility should come to us made from webapp and always receive a name with which we want to share the file.

We agreed on making filename mandatory, modifying spec.

nimeacuerdo commented 4 months ago

what is left to proceed with this?

pladaria commented 4 months ago

Has this been considered? https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API

Web Share API is not supported in android webviews. So this proposal LGTM

atabel commented 4 months ago

https://jira.tid.es/browse/WEB-1942