Sending expected file name via parameter to override random_url
Closed this issue · 3 comments
This is the fruit of the discussion #216
Normally users can decide resulting filename by sending filename
on multipart request, as long as server does not use random_url
In case #217 is implemented, an extra argument like --file-name
could be helpful to override random path result (on servers which explicitly allow overriding the random_url
setting). An example:
# normal operation with random_url
$ rpaste imgurdownload.jpg
http://example.com/some-random-string.jpg
# if overriding allowed
$ rpaste --file-name i-dont-know-what-i-expected.jpg imgurdownload.jpg
http://example.com/i-dont-know-what-i-expected.jpg
Such a parameter would also be useful no matter what. Right now it doesn't seem possible to set the filename if random url is not used either. So apparently that was an oversight earlier.
I looked into this, but it seems a bit more complicated than expected.
Firstly, the arguments are not available to the upload
function. Thus one either has to refactor quite a bit, or use a workaround and use the Config struct. The latter is easier but makes less sense, since this would also allow people to set it in the config file, which makes no sense at all.
Just for getting ahead quickly, I implemented the workaround, but for some reason setting the header for the request does not work. You can have a look at the code here: tessus@9c33fd1
I haven't had the time to debug the request/response via tcpdump.
I was mixing up a few things in my last comment. I was able to code it. I still have to update the README. Will do that tomorrow and then I'll create a PR.