• Resolved Mark

    (@codeispoetry)


    With shortcode “download”, ZotPress generates links to attachments through the Zotero API. In request.dl.php it sets the filename to be “download-[itemid]” (and extension based on content type), resulting in filenames that are uninformative to users.

    Zotero attachments usually have meaningful filenames, especially since Zotero renames attachments based on metadata by default. This is available as a filename property in the Zotero API. It would be wonderful if ZotPress would use that instead of generating its own filename.

    Proposal: Use the attachment’s own filename property instead of making up one.

    Alternative proposal: Allow users to set a custom filename format (e.g. %author%_%yyyy%_%title%.pdf.

    To be honest I’m only including the alternative proposal to show that the first one is much more straightforward. If you let users handle filenames on the Zotero end it saves everyone trouble.

    • This topic was modified 4 years, 1 month ago by Mark.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Mark

    (@codeispoetry)

    Still hoping that this might be relatively straightforward for @kseaborn … Mucking around in the ZotPress code myself I haven’t been able to retrieve the original attachment filename but it sure would be available somewhere?

    Plugin Author Katie

    (@kseaborn)

    Yes, I plan to have this set up for the next version. The problem is Zotpress has to make two requests (which take time and server load) because it has to request (a) the meta data and (b) actual file separately. So I think I made a decision (a long long long time ago) to just have one request for efficiency. But maybe things have sped up since then. It’s too bad that I can’t seem to extract the original filename from the file data itself, or if only it was included in the header info or something …

    Thread Starter Mark

    (@codeispoetry)

    Thank you! I see, I guess this is because filename is a property of attachment items and that requires a separate request. (What I don’t understand is how you’re able to find out the content type in one go, which you already do; somehow I assumed the filename was also within reach then.)

    I guess if the data can be cached like most metadata seems to be this would have a negligible effect on first load only; already I find it’s pretty very fast, for instance it takes only a few secs to retrieve everything anew when refreshing the cache. So I’m looking forward to seeing how this works out!

    (And if multiple requests really turn out too slow I suppose the alternative I mentioned, of cobbling up a more informative name on the fly based on the metadata you do know, might be a useful workaround. Sth like author_year.pdf or for more disambiguation Author_year_First_five_words_of_title.pdf or even (uglier but unique) author_year_itemid.pdf would already be more user-friendly than the current format.)

    Thanks so much for your work on this, I very much look forward to the updates!

    • This reply was modified 3 years, 9 months ago by Mark.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Use attachment filename as download filename’ is closed to new replies.