Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Feature: ability to serve a temporary static PDF #36

Open
shankie-codes opened this issue Mar 10, 2017 · 6 comments
Open

Feature: ability to serve a temporary static PDF #36

shankie-codes opened this issue Mar 10, 2017 · 6 comments

Comments

@shankie-codes
Copy link

I'm making something within a Saleforce.com APEX page where I had to use their own AJAX client, where responses are always parsed as text, rather than giving me the option to parse the response as a blob, as I'd normally do with SuperAgent. As a result, I need electron-render-service to send back a temporary URL to the client where they can then perform a simple get to the resource.

I'm working on a PR where the render service saves a file to public/download-[timestamp].pdf. It then returns the URL of the file to the client as JSON. Once the file has been accessed, it is deleted.

I've got it working in the narrow use-case for my client, but I was thinking of turning it into a PR for the project. I've designed it so that there's anther query parameter sendBinaryOrURL which you can set to binary or url, defaulting to binary if you don't provide the parameter (replicating the current flow).

Would you be interested in accepting a PR for this?

@msokk
Copy link
Owner

msokk commented Mar 12, 2017

You are requesting the render service from front-end, right?

What about making a flag for tweaking Content-Disposition? Currently it is inline, causing the PDF to load in page, but it could be attachment, forcing the browser to download the PDF.

Hmm, actually that could be the new default, as it shouldn't affect anything other than browsers. So you could generate a regular link, which would download the PDF. Of course the latency depends on the complexity of the page, etc.

I also have a longstanding task open to add an async API, but haven't gotten to it. Planned to have a postback URL, but that's no use in FE.

@shankie-codes
Copy link
Author

Yes, I'm requesting the render service from the Express front end.

Your change would make sense and certainly work for most use cases (as you say, makes sense as the default).

By async, I assume you mean something like "send a request with a callback URL to POST to". That would work well in some cases as well.

My use case is somewhat different however: I have minimal control over the AJAX client, so the response is always parsed as text. I can email you credentials for my test server if you want to have a look... or, I'm happy to accept that mine is an edge case 😄

@msokk
Copy link
Owner

msokk commented Mar 20, 2017

My use case is somewhat different however: I have minimal control over the AJAX client, so the response is always parsed as text. I can email you credentials for my test server if you want to have a look... or, I'm happy to accept that mine is an edge case 😄

I'm just wondering if you have an alternative way not to use AJAX client at all and just generate an link to a URL to download?

@shankie-codes
Copy link
Author

Hey @msokk looks like you meant to post something above but didn't quite manage to!

@msokk
Copy link
Owner

msokk commented Mar 20, 2017

Fixed the quotation. You could send me the test access if it is still relevant and not a big bother.

@shankie-codes
Copy link
Author

Hey @msokk , sorry, I completely forgot about this. I would still like to do this as I think it's a useful enhancement to the project. I'll email you credentials now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants