Rename file during upload

Advertisement

lee_r
Guest

Rename file during upload

Situation:
You upload a 100 KB PHP/Python/Ruby/whatever file to your webserver.
During the upload (especially on slow lines) the file can possibly be retrieved partially because parsing doesn't work yet.
Just imagine the login data to your database can be seen in clear text in the browser of someone accidentally loading a website while you upload it.
This also affects editing and saving a file in WinSCP.

Solution:
Option for uploading the file renamed like $FILENAME_temp$threerandomchars and automatic renaming to the original filename when uploading is finished.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Rename file during upload

If you use SFTP protocol, you may enable transfer resuming for all files, which results in behaviour you describe.

Reply with quote

lee_r
Guest

Thanks for the hint, but this doesn't seem to work when you want to overwrite existing files, only when uploading new files.

Reply with quote

martin
Site Admin
martin avatar

lee_r wrote:

Thanks for the hint, but this doesn't seem to work when you want to overwrite existing files, only when uploading new files.
I do not think so. What does happen if you are overtwritting the existing files?

Reply with quote

lee_r
Guest

I was able to nail down the circumstances under which the problem happens:
in binary transfer mode both uploading and overwriting is done correctly using $FILENAME.filepart.
I've tested this with an EXE and a ZIP file -> both fine, because it's binary transfer.

Then I tried the same using a 2 MB TXT file and a 150 KB PHP file (text mode transfer)
Both were uploaded using the filename without the temporary filepart extension.
The same goes for overwriting, the previous file is just being deleted and then the upload starts using $FILENAME.

Looks like a bug when using text transfer mode.
If it helps I'm using WinSCP 3.8.2 (Build 330).

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

lee_r wrote:

Then I tried the same using a 2 MB TXT file and a 150 KB PHP file (text mode transfer)
Both were uploaded using the filename without the temporary filepart extension.
The same goes for overwriting, the previous file is just being deleted and then the upload starts using $FILENAME.

Looks like a bug when using text transfer mode.
If it helps I'm using WinSCP 3.8.2 (Build 330).
Resuming is not supported for text transfer mode. You may need to force binary mode.

Reply with quote

Guest

martin wrote:

Resuming is not supported for text transfer mode. You may need to force binary mode.
Agreed, but resuming isn't what's needed, it would just be great that $FILENAME is being uploaded as $FILENAME.filepart and renamed to $FILENAME when uploading has finished.

Reply with quote

martin
Site Admin
martin avatar

Agreed, but resuming isn't what's needed, it would just be great that $FILENAME is being uploaded as $FILENAME.filepart and renamed to $FILENAME when uploading has finished.
I understand your problem. Maybe if more people ask for it, I'll consider adding such a feature.

Reply with quote

Advertisement

You can post new topics in this forum