Skip to content
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

[Feature] API for sending in file #37

Closed
PepperAddict opened this issue Sep 1, 2020 · 1 comment
Closed

[Feature] API for sending in file #37

PepperAddict opened this issue Sep 1, 2020 · 1 comment

Comments

@PepperAddict
Copy link

PepperAddict commented Sep 1, 2020

What problem is this request going to solve?
It would be nice to be able to run a file request through the SDK rather than sending it in as a post request with my token key.
When sending a file as a post request to /v2 or /v2/file endpoint from a host such as ngrok.io, I get a CORS issue.
If I send a file to /v2 endpoint from a published build from website.monday.com, I am able to successfully send a file through a post request. Unfortunately /v2/file still gets a CORS issue.

What is the solution you'd like to see?
It would be great to send a file through the SDK. I know that most of the queries/mutations for monday.api() are JSON string so it's going to be different than file that is multipart/form-data. I don't know what goes on in house as it gets sent home with window.parent.postMessage(), but my recommendation is sending it with a different function. So instead of Monday.api(query, options) , create a new one and call it something like: Monday.file()

const formData = new FormData();
formData.append("variables[file]", file, filename );
const query = `mutation addFile($file: File!) {add_file_to_update (update_id: 1234, file: $file) {id}}`;
formData.append("query", query )

Monday.file(query, {form: formData})

Or if the backend is in charge of converting file to formdata, then the user could write:
Monday.file(query, {variables: {update_ID: 123, file: file}})

Describe alternatives you've considered
I have it already working by sending the file to the backend which bypasses the CORS issue straight to the v2/file endpoint since I can't access it through the client side.

Additional information
I created a post regarding this topic here: https://community.monday.com/t/requesting-code-example-for-file-upload-via-mondays-sdk-client-side/10099

And here's a separate discussion regarding the CORS limitation on the client side via file post requests: https://community.monday.com/t/cors-issue-when-uploading-file-with-api-v2/9993

@PepperAddict
Copy link
Author

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

1 participant