0 votes

client.GetFileHash(remotePath, FtpHashType.MD5) results in exception "MD5 not allowed" when remotePath contains a space in the parent folder of the file.
When I remove the space, there is no error anymore, but I need to support foldernames with spaces.

by

1 Answer

0 votes

This might be a problem with your FTP server.
Ftp.dll encloses filenames with spaces using quotes:

C : OPTS HASH MD5
C : HASH "hash with space.txt"

Turn on logging, to see the exact commands:
https://www.limilabs.com/blog/logging-in-ftp-dll

Alternatively you could change current folder first using Ftp.ChangeFolder and issue Ftp.GetFileHash without parent folder path.

by (300k points)

The Limilabs log output for parent folder with space indeed shows quotes, yet the XMD5 fails due to "MD5 not allowed":

C: XMD5 "<folder_path>/Parent Folder/<filename.ext>"
S: 550 MD5 not allowed.

If I copy the file and parent folder and replace the space by an underscore, then the XMD5 command shows no quotes anymore and successfully returns hash:

 C: XMD5 <folder_path>/Parent_Folder/<filename.ext>
 S: 214 0867072c3829e373189ea0df93fd2b5a



When trying form FileZilla I get following behaviour:

Command:    XMD5 <folder_path>/Parent_Folder/<filename.ext>
Response:   214 0867072c3829e373189ea0df93fd2b5a

--> no space + no quotes: OK

Command:    XMD5 "<folder_path>/Parent_Folder/<filename.ext>"
Response:   550 MD5 not allowed.

--> no space + with quotes: NOK

Command:    XMD5 "<folder_path>/Parent Folder/<filename.ext>"
Response:   550 MD5 not allowed.

--> with space + with quotes: NOK

Command:    XMD5 <folder_path>/Parent Folder/<filename.ext>
Response:   214 0867072c3829e373189ea0df93fd2b5a

--> with space + no quotes: OK

So it now seems the space is not really the problem but the quotes.

The FTP server we use is CrushFTP.
Unless Limilabs FTP.dll has an option for sending the commands without quotes, I will contact CrushFTP for a solution.

Ftp.ChangeFolder could be plan B, but this is an extra step so it will slows down the processing.

Please try the latest version (2.0.23159.2244):
https://www.limilabs.com/ftp/download

Thanks for implementing a fix but in the meanwhile, I already have a workaround in place. Thanks for your quick support!

...