Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial file uploads being automatically deleted

Tags:

c#

http

apache

I have some c# code that is doing some file uploads to my apache server via HttpWebRequests. While the upload is in progress, I am able to use ls -la to see the growing file size.

Now, if I for example pull my computers network cable, the partial file upload remains on the server.

However, if I simply close my c# app, the partial file is deleted!

I assume this is being caused by my streams being closed gracefully. How can I prevent this behavior? I want my partial file uploads to remain regardless of how the uploading app behaves.

I have attempted to use a destructor to abort my request stream, as well as call System.Environment.Exit(1), neither of which had any effect.

like image 471
Julien Avatar asked Jul 16 '26 20:07

Julien


1 Answers

Pulling the network cable will never be equivalent to aborting the stream or closing the socket, as it is a failure in a lower OSI level.

Whenever the application is closed, the networking session is aborted and any pending operation cancelled. I don't think there's any workaround, unless you programmatically split the file transfer in smaller chunks and save them as you go along (this way you'd have a manual incremental transfer, but it requires some code server-side).

like image 157
Strillo Avatar answered Jul 19 '26 08:07

Strillo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!