Additional breaking lines after upload
See original GitHub issueDescribe the bug Hello! I’ve encountered a bug with uploading a plain text file. It adds a breaking line per every line in the original file.
Example code
import { Client as FtpClient } from 'basic-ftp';
(async () => {
const ftpClient = new FtpClient();
await ftpClient.access({});
await ftpClient.uploadFrom(
createReadStream(resolve('static', 'file.txt'), 'utf8'),
'file.txt',
);
})();
Local file - the original one
a
b
c
Remote file - after upload
a
b
c
Console output
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 38 of 300 allowed.
220-Local time is now 21:21. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 10 minutes of inactivity.
Login security: No encryption
> USER ...
< 331 User ... OK. Password required
> PASS ###
< 230-Your bandwidth usage is restricted
230-OK. Current restricted directory is /
230 Max allowed filesize is 1048576000 bytes
> TYPE I
< 200 TYPE is now 8-bit binary
> STRU F
< 200 F OK
> OPTS UTF8 ON
< 200 OK, UTF-8 enabled
> OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;
< 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
Connected!
Trying to find optimal transfer strategy...
> EPSV
< 229 Extended Passive mode OK (|||58389|)
Optimal transfer strategy found.
> STOR file.txt
< 150 Accepted data connection
Uploading to ... (No encryption)
< 226-File successfully transferred
226 0.336 seconds (measured here), 53.52 bytes per second
Which version of Node.js are you using? 12.2.0
Additional context The example code is enough, but you can also see qusly-core.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Multipart form file upload - Uploaded file have sometimes ...
The problem is that it sometimes happens that an uploaded audio file has a line break at the end of the file that...
Read more >Why are text file line breaks wrong, after the file is ...
Line breaks are duplicated. It seems like there's additional empty line between every line. There's strange symbol/character at the end of every ...
Read more >Line breaks in text fields - A Beginner's Guide to Clean Data
On the other hand, if a line break occurs within a text field, it's unlikely that it is followed by four digits. Editors...
Read more >The Dos and Don'ts of Adding an HTML Line Break
Learn what a line break is, how to add one in HTML, and why a line break might not be working in your...
Read more >Add line or page breaks in Pages for iCloud
Add a page break: Click the Insert button in the toolbar, then choose Page Break. If you don't see Page Break, you're in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Of course, please do reopen this issue if there is indeed another reason at play where I could fix something.
To sum up: This library does not alter the content of any files. By default, it transmits using binary transfer mode.
Originally, FTP is supposed to change newline characters of text files according to the OS of the transfer target when using ASCII transfer mode. Today, this is a questionable practice since all editors should be able to handle newline conventions from both Windows and Unix-like OSes.
This library will not alter newline characters. It will not automatically switch to ASCII transfer mode when there is a text file. And it won’t alter newline characters if the user explicitly switches to ASCII transfer mode.
I’m writing this as documentation of the position this library takes. What has been described here in this issue is a different thing though. Even though this library is not changing anything, text files seem to be different when downloaded. I have to say that I suspect something to be wrong with the FTP server. I suspect that Filezilla does automatically switch to ASCII transfer mode and applies changes to newlines which somehow then works well with the server. But the server apparently can’t handle files just being handed to it without any change, possibly with newlines that don’t fit the OS the server is running on.
I’ll close this issue because I don’t really see what I could do besides starting to also edit files in ASCII mode and automatically selecting ASCII mode if there is a text file. And I don’t want to do the latter. I find editing files based on the OS of the transfer target an extremely weird thing to do.
I will reconsider if the error describes in this issue is something that happens often enough.