Patch lua-spore to properly set filename in form-data#2123
Conversation
|
Reference issue: #2122 |
|
What if the filename can and should contain a subfolder? On mobile right now, and a bit rusty, but that pattern only keeps the final path component, right? |
|
Yes the pattern only keeps the final component but the filename inside the form-data should be just a reference to what the file should be called on the server and shouldn't store the path of the file; filename is just a suggestion on how the file should be called on the server. So you actually provide a full path to the lua-spore method in order to fetch the file binary data but inside the form-data you just provide the filename as an information to tell the server how to name that file. |
|
Ah, okay ;). LGTM then ;). |
|
Now merged upstream, so I suppose we can simply revert this now. ^_^ |
|
Yes I confirm it's been merged upstream. |
During the development of a koreader plugin I encountered the following problem using the
lua-sporelibrary.I have an
api.jsonfile like thisWhen I invoke the
upload_filemethod like thisThe request is succesfully sent but the server is unable to save the file locally because of a problem in the way the form-data is built.
Until now when you use an absolute path inside the
filefield the lua spore library would send a form-data with the filename set exactly to the absolute path you specified while instead it should just put the filename of the corresponding file.This fix aims to resolve that problem and simply by getting the last part of the path I'm able to correctly set the
filenamefield inside the form-data and correctly save the file on the backend.So we move from something like this
to
This change is