Mobile app version of vmapp.org
Login or Join
Yeniel560

: How can I make Apache wait for images to be fully written to the storage drive before serving them? I'm using fswebcam to take pictures from my webcam and write them to /var/www so that anybody

@Yeniel560

Posted in: #Apache #Apache2 #Download #Images

I'm using fswebcam to take pictures from my webcam and write them to /var/www so that anybody can view them from my website.

The problem is that my server is a Raspberry Pi with a slow SD card. It takes several seconds to write the image to the SD card. If a user requests the image while it is still being written, they'll get a half-finished version of the image:




Is it possible to make Apache wait for an image to be fully written before it serves it?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Yeniel560

2 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

Moving a file within the same disk is a very quick (nearly instantaneous) operation. Instead of saving them directly to www save them to a different directory on the same disk where Apache can't see them. Then when they are fully saved, move them into place in

10% popularity Vote Up Vote Down


 

@Correia994

I'm not sure about apache but I think some scripting language should be able to detect if a file is being written (perhaps using file handles?)

You can then wait for it to finish and serve the file.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme