Problem with cffile action read

Hallo,
i have a problem with “cffile action read”
On the server (linux) I mounted an ftp folder (curlftpfs)
I have created an application that allows you to upload files via ajax (dropzone) and save the files on the mounted folder.

<cfloop list = "#form.fieldNames#" index = "i">
<CFFILE ACTION = "copy"
   source = "#FORM [i]#"
    DESTINATION = "#foldermounted#/#FORM [i]#"
    NAMECONFLICT = "Overwrite">
</cfloop>

The same application reads the files contained in the folder via CFFILE and distributes them via cfcontent

<cffile action = "readbinary" file = "#foldermounted#/#file_name#" variable = "myfile">
<cfheader name = "Content-Disposition" value="inline; filename = test.pdf">
<cfcontent variable = "#myfile#" reset="yes" type="application / PDF">

Normally PDF files are read and distributed regularly.
Some PDF files instead return this error

Lucee 5.3.9.160 Error (application)
Message Can’t read file [/cartellamontata/test.pdf]

Detail Input / output error

Stacktrace
lucee.runtime.exp.ApplicationException: Can’t read file [/cartellamontata/test.pdf]
at lucee.runtime.tag.FileTag.actionRead (FileTag.java:699)
at lucee.runtime.tag.FileTag.doStartTag (FileTag.java:433)

If I change the code

<cfheader name = "Content-Disposition" value = "attachment; filename = test.pdf">
<cfcontent deleteFile = "no" file = "/cartellamontata/test.pdf" reset = "yes" type = "application / unknown">

the file is downloaded, but the pdf is damaged.

If I access the folder where the file is saved via an FTP client and download the file, it opens regularly; if I print this same file (for example with “Microsoft Print to pdf”) and upload it through the application, the file no longer gives any error.
What could be the cause of this error?
Could it be the software that generated the original PDF (Acrobat PDF Maker 11 for Word)?

I forgot …
The mounted folder is located on an FTP accessible cloud
(Cloud storage Object by cloud.it)

i doubt it’s related to the PDF software.

can you read and write simple text files to the mounted folder?

does the user which lucee runs under have access to the mount?

Thanks Zack
for your quick reply.

can you read and write simple text files to the mounted folder?

YES

does the user which lucee runs under have access to the mount?
YES

Out of about 1000 PDF documents uploaded it only occurred 2 or 3 times.

If I download the file in error via FTP with Filezilla and open it with Adobe Reader, it opens.

  1. If I regenerate the PDF just downloaded (with Filezilla) using the “Microsoft print to PDF” virtual printer and upload again through my application, cffile does not go into error.
  2. If I upload the original file (not regenerated) through my application or through Filezilla cffile it goes into error.

The problem is just with that file as if it is corrupt, but it really isn’t

can you do a binary diff on the corrupted file vs the original to see what’s changing?

This is the win 10 comparison
RG004RAGUSA.pdf is the one who does not make problems
RG004RAGUSA.1.pdf is the one in error

C:\Users\Administrator>fc C:\Users\Administrator\Desktop\cfr\RG004RAGUSA.pdf C:\Users\Administrator\Desktop\cfr\RG004RAGUSA.1.pdf
Confronto in corso dei file C:\USERS\ADMINISTRATOR\DESKTOP\CFR\RG004RAGUSA.pdf e C:\USERS\ADMINISTRATOR\DESKTOP\CFR\RG004RAGUSA.1.pdf
***** C:\USERS\ADMINISTRATOR\DESKTOP\CFR\RG004RAGUSA.pdf

<?xpacket end="w"?>

<</Filter/FlateDecode/First 6/Length 63/N 1/Type/ObjStm>>stream
hÌ260R0P░▒Ðw╬/═+Q0ı¸╬L)Ä660♥è♠)↑éI(BÖâ¿X²É╩éT²Ç─¶Èb;;Ç
:heart:
<¿►■
<</Filter/FlateDecode/First 6/Length 193/N 1/Type/ObjStm>>stream
╝ç╩ùêK\Vs­3Ç┘┤Ñx¦ Àö═®┘▼Ú x­£vf┘a▒)q║Ó>¢QÛ^÷öƒ$|I Ñ☺│┘©z╠_,┼×ZI┐ë═Äå1│u;¥♫È▀♂M↕)ÃP4▼▲░B└§ÈK▄7:y
;èA4âû♂K░¯@À|ªƒÚéX!Zwõ­▼ΰçƒä├ÏEı♥À±iøCjàõ«³☻¼;¾(]T’}ª7■éáÊ/K╗¦>♦↑
DèK¶
<</DecodeParms<</Columns 5/Predictor 12>>/Filter/FlateDecode/ID[<4A3A6D37D8A93449AE909022B7ED452B><7F
AF553DB8ECEE4E9440D2B7C06632B7>]/Info 303 0 R/Length 170/Root 305 0 R/Size 304/Type/XRef/W[1 3 1]>>stream
hÌbb
,>§L«5​:female_sign:L​:female_sign::female_sign:î! ÆS§D2ƒÆLç\┴ÔbÊ Æî<w┴ý8►{®;Xì☺êõZ "#¸üHªP░©"ÿ¶♦ø⌂ ,╬☺Ê┼h ▬?☻6þ2ÿ}¶¼♠l↨k/X\ ñÆ⌂/Xv♫ÿö║¨Ãƒ¦ 6É"╣ âHV#Æ82╔°↨╗8Õ$Ò'ZÖ<JÄdÆq¯h8îÆúÚèÌ$ËEH=☻►
Þ→←Ç
startxref
116
%%EOF
***** C:\USERS\ADMINISTRATOR\DESKTOP\CFR\RG004RAGUSA.1.pdf


Original File RG004RAGUSA.1.pdf (in error) is 512 kb
Regenerated File RG004RAGUSA.pdf (it work) is 514kb

This is dump of FileInfo(’/pratiche/10003/RG004RAGUSA.1.PDF’)

Struct
Entries: 11
attributes string
checksum string 4edce7490cd5ed0e88f20ff2aad00b70
dateLastModified Date Time (Europe/Rome) {ts ‘2022-09-26 12:15:00’}
execute boolean true
mode string 777
name string RG004RAGUSA.1.PDF
path string /pratiche/10003/RG004RAGUSA.1.PDF
read boolean true
size number 525815
type string File
write boolean true

and…
This is dumps of FileInfo(’/pratiche/10003/RG004RAGUSA.PDF’)

Struct
Entries: 11
attributes string
checksum string 38cb6f710c3d9515e33a9989f193e5bb
dateLastModified Date Time (Europe/Rome) {ts ‘2022-09-26 12:17:00’}
execute boolean true
mode string 777
name string RG004RAGUSA.PDF
path string /greenfuelcorporation/pratiche/10003/RG004RAGUSA.PDF
read boolean true
size number 619835
type string File
write boolean true

Thank You Very Much Zack,
you opened my eyes.

Practically in the file that cffile cannot read, the concluding piece (which ends with “%%EOF”) is missing,

It is possible that cffile fails for this reason.

I just need to figure out if the piece was already missing in the file before the upload, or if it was lost during the upload or when writing to the mounted folder

1 Like