Am I correct in assuming that you are passing on the output stream directly to the input stream of the PUT request? So there is no byte-buffer-caching on your side.
There’s a 1 MB buffer, but that’s not the problem.
As I understood you, there is still a small window of time where is filedescriptor is closed but the PUT is still ongoing.
Some maybee ugly workarround may be to have filelock table (until the PUT request finishes) and delay copy/rename/move/delete operations?
Yes, I have thought about that. Surely much work for little result, and such things look to me as if they would cause 10000 new bugs. But maybe one day…