mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 243 forks source link

Upload An Image Corrupts It #95

Closed PaulBGD closed 9 years ago

PaulBGD commented 10 years ago

I cannot seem to upload images without them corrupting. I don't see anything in the documentation, so I suppose this is an issue?

mscdex commented 10 years ago

Can you post the code you're using?

PaulBGD commented 10 years ago

Sure! Sorry for the spacing. Do you need to see anything else?

                            c.put("../images/" + files[i], "new/game/images/" + files[i], function(err) {
                                if(err) {
                                    throw err;
                                }
                                if(--todo == 0) {
                                    console.log("Finished!");
                                    c.end();
                                }

                            });
mscdex commented 10 years ago

Can you describe the corruption? Are the files zero bytes? Are there no files at all? Or something else?

PaulBGD commented 10 years ago

The files are created, however they have < 20 bytes. Also, I checked that the end method is only being called after the last one is uploaded.

PaulBGD commented 9 years ago

Just realized I left this open. I don't remember the exact solution was, but I'm pretty sure I just closed the stream early.