jptreen
(jptreen)
July 25, 2021, 11:08am
1
Hey!
I've checked the github issue queue, and this forum, and hadn't been able to find anything on this.
Looking through the MDN Content-Disposition Docs (I would link, but was not allowed)...
Content-Disposition: attachment; filename="filename.jpg"
would set a filename different from the url when a user in a browser clicks 'save as'. I would expect --auto-filename
to respect that header if it's been set, it sounds like that setting should do that.
Instead, as per the copyurl docs , it does:
-a, --auto-filename Get the file name from the URL and use it for destination file path
Any reason rclone could not get a little cleverer here and respect the filename directive, if set?
jptreen
(jptreen)
July 26, 2021, 6:22pm
2
FTR, I've added a PR on this issue. I changed my thinking a little, and gone for a new switch that depends on --auto-filename
being active.
rclone:master
← jptreen:auto-filename-header
opened 04:28PM - 26 Jul 21 UTC
#### What is the purpose of this change?
To set preferred download filenames … for HTTP requests, RFC 6226
specifies a 'filename' directive, available within 'Content-Disposition'
header, and suggests both token and quoted string syntaxes should be allowable
for the filename directive. i.e.: either `filename=name.txt` or
`filename="name.txt"` should be acceptable.
See below for details:
https://httpwg.org/specs/rfc6266.html#disposition.parameter.filename
https://httpwg.org/specs/rfc6266.html#advice.generating
`--auto-filename-header` is designed to work in conjunction with `--auto-filename`, honoring the filename directive when retrieving files from a server.
Directives contained within the `Content-Disposition` header are semicolon delimited, and can vary in length and order. Consideration had to be given to parsing entries like `inline; filename="file.txt";` as well as the more straightforward examples above.
#### Was the change discussed in an issue or in the forum before?
I raised it on the forum, got no response, and thought it was an clear enough issue to tackle myself without altering existing functionality. Maybe that was good enough. If not, maybe a rogue PR is enough to get a response. 😉
https://forum.rclone.org/t/copyurl-auto-filename-could-be-cleverer-and-respect-the-http-content-disposition-optional-directive-filename/25553
#### Checklist
- [x] I have read the [contribution guidelines](https://github.com/rclone/rclone/blob/master/CONTRIBUTING.md#submitting-a-pull-request).
- [x] I have added tests for all changes in this PR if appropriate.
- [x] I have added documentation for the changes if appropriate.
- [x] All commit messages are in [house style](https://github.com/rclone/rclone/blob/master/CONTRIBUTING.md#commit-messages).
- [x] I'm done, this Pull Request is ready for review :-)
system
(system)
Closed
September 25, 2021, 2:22pm
3
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.