Skip to content

Chrome extension file access issues #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MattTheCuber opened this issue May 31, 2022 · 6 comments
Closed

Chrome extension file access issues #18

MattTheCuber opened this issue May 31, 2022 · 6 comments
Assignees

Comments

@MattTheCuber
Copy link

Using https://unpkg.com/convertapi-js/lib/convertapi.js

I guess this is more of a feature request. I am trying to write a chrome extension that grabs some image URLs then uses this API to convert it to PDF. My problem is that the files are protected behind authorization headers. When I use new URL it removes the authorization headers and the request fails. I am willing to modify my local copy convertapi.js if needed.

I have tried (for several hours) to use the file type instead, but it looks like you need to use the actual File object type and I cannot get this in a chrome extension as far as I know. Because, if I try to download the files it only gives me the downloadId. If you have suggestions for alternatives I would be happy to try them. Creating this issue is my last resort so hopefully there is some way I can get this to work.

@JonasJasas
Copy link
Collaborator

You can upload files to our file server using Fetch API:

https://v2.convertapi.com/upload?HeaderName=Authorization&HeaderValue=BearerXXX&url=http%3A%2F%2Fexample.com%2Ffile.doc

  • HeaderName - sets header name
  • HeaderValue - sets header value

Then use the uploaded file ID in the conversion request.
Read more here: https://www.convertapi.com/doc/upload

@MattTheCuber
Copy link
Author

And what if there are multiple authorization headers?

@JonasJasas
Copy link
Collaborator

JonasJasas commented Jun 10, 2022

For such exotic scenarios, I would use FaaS (Cloudflare workers, Amazon functions) to add these headers.
Another option is to try if this Chromium fix would work: https://bugs.chromium.org/p/chromium/issues/detail?id=688906#c73
The idea is to request file to the browser and then redirect stream to our file server (use the response body as a source for the request body).

@JonasJasas
Copy link
Collaborator

Just found out that is not yet implemented. So for now use FaaS solution.

@MattTheCuber
Copy link
Author

I have never heard of this FaaS solution before. Any chance you could link some documentation or a guide?

@JonasJasas
Copy link
Collaborator

https://workers.cloudflare.com/
https://developers.cloudflare.com/workers/examples/alter-headers/

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

No branches or pull requests

2 participants