Kërkoni te Asistenca

Shmangni karremëzime gjoja asistence. S’do t’ju kërkojmë kurrë të bëni një thirrje apo të dërgoni tekst te një numër telefoni, apo të na jepni të dhëna personale. Ju lutemi, raportoni veprimtari të dyshimtë duke përdorur mundësinë “Raportoni Abuzim”.

Mësoni Më Tepër

what is the max length of downloadable file name?

  • 6 përgjigje
  • 1 e ka hasur këtë problem
  • 2 parje
  • Përgjigjja më e re nga Tonnes

more options

I am downloading a file using below statement in JavaScript,

browser.downloads.download({url: pdfUrl,filename:name},function(download) {}

Here the filename is custom build name. If the file name total characters goes beyond the 226 I am getting below error.

"[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIAnnotationService.setPageAnnotation]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://app/modules/DownloadsCommon.jsm :: onDownloadChanged :: line 781" data: no"

Can you please let me know If I am missing anything here?

Thanks In Advance,

Thank you, Yogesh

I am downloading a file using below statement in JavaScript, browser.downloads.download({url: pdfUrl,filename:name},function(download) {} Here the filename is custom build name. If the file name total characters goes beyond the 226 I am getting below error. "[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIAnnotationService.setPageAnnotation]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://app/modules/DownloadsCommon.jsm :: onDownloadChanged :: line 781" data: no" Can you please let me know If I am missing anything here? Thanks In Advance, Thank you, Yogesh

Krejt Përgjigjet (6)

more options

I’m not entirely sure, but think the answer is in your question. The maximum path length value may vary per file system, but will be around 250-260 for most of them (please use a search engine for that).

For Windows 10, you could work around it by enabling "NTFS long paths", but you will likely break compatibility. How about using a shorter name or the file?

more options

Thanks Tonnes for replying,

Actually the file name is generated based on few attributes. Which I cant change to shorter length.

more options

The main problem is the file path (nested directory chain). If you would save the file to a deeply nested folder with a long path name then you are likely to run much earlier into problems. This will also happen if you would move the file at a later time to another folder and you are near a max-length.

more options

By default files are downloaded to Download folder in windows.

If I choose different folder then also I am getting error.

If i give below file name its giving error,

"Sensitivity-of-nextgeneration-sequencing-metagenomic-analysis-for-detection-of-RNA-and-DNA-viruses-in-cerebrospinal-fluid-The-confounding-effect-of-background-contamination_2017_Advances-in-Experimental-Medicine-and-Biology.html"

and if I give Below name its working fine and downloading properly,

"sitivity-of-next-generation-sequencing-metagenomic-analysis-for-detection-of-RNA-and-DNA-viruses-in-cerebrospinal-fluid-The-confounding-effect-of-background-contamination_2017_Advances-in-Experimental-Medicine-and-Biology.html"

I think Firefox having some constraint on file name length.

I may be wrong.

FYI ...I am using Firefox Version 50.1.0.

more options

What you could do is create a folder for downloads in the primary directory. Example; c:\Downloads

more options

Please don’t try to move mountains. As said earlier and confirmed, you would be better off using proper and shorter names that make sense, or your users will run into problems. Firefox has no issue in this, it’s the OS limiting the max path length (which includes the file name!) for reasons that have probably been overthought by many.

If I was an active (security) software developer and were to decide, I might consider adding an option to set a character limit for names of allowed files to download or another algorithm just because the one above looks hazardous. Also, you simply cannot expect every user to have a download folder of e.g. 8 characters maximum in the root folder just to allow your downloads.

If you want this to work for testing purposes only, you know your limits so you could create a fixed folder with a short name and use a limitation in your script to generate the name (most obvious), or set a limit to the length of document names themselves (harder to achieve). If you do need to add all attributes, you could let them strip / only read a number of characters in order to use their first 32 (times 2?) characters only, for instance. The way things look right now is that a web page slug and the original file name or a name created by its title is grabbed, so I wonder why the slug is included - I wouldn’t like to see such a file on my disk, and strip the slug anyway.

You may also want to keep generic file name lengths for modern operating and file systems in mind - around 129 is quite common (half max path value by conicidence?), so I would just make sure not to exceed that either.