Add support for relative path for file attachments#203
Add support for relative path for file attachments#203monkbroc wants to merge 2 commits intoform-data:masterfrom
Conversation
|
Thank you for the PR. |
|
Sure. This is for the Particle API for internet-connected microcontrollers. One API endpoint supports cloud compiling of firmware source code. It takes a multi-part upload with source code files as file uploads. The compile server puts the files in their relative paths, compiles them and returns a binary. For example, if you send Without the |
|
I see. Thanks for the details. What if we do it in more standard compliant way? (https://developer.mozilla.org/en-US/docs/Web/API/FormData/append) and |
|
Thanks for the quick response and pointing to the standard. The issue with your proposed approach is that it would be a breaking API change for form-data. Current callers expect an absolute path to be changed to a basename. (BTW I don't think this is captured in a test. I will add this to the PR) Another implementation would be to add a flag |
|
I changed the implementation. Do you feel this is more standards-compliant? form.append('field1', data, {
more: 'things',
filename: 'lib/gps.cpp'
includePath: true
}); |
|
Is there a chance to merge this in? I can rebase if it helps. |
|
Hey sorry, I've been far from this part of the internet for too long. I like your solution that it doesn't break compatibility. What do you feel like, if we add |
|
👍 |
I need to be able to provide a relative path in addition to the filename for an attachment.
The change adds an optional option
relativePathtoappend()to include a path before the file basename in the form multi-part header.I added a test for the new behavior and a line in the Readme.
This is similar to #181.