mardi 19 juin 2012 20:21I have a data URL with a PNG image. Is there a way to save this to disk?
Toutes les réponses
mercredi 20 juin 2012 14:03Modérateur
You can create an image object set its URL and then use it's blob to write to a file. There are several forum posts on saving image data. You could also directly save the data from an xhr request (I don't know if there is an example of that but should be pretty easy)
Jeff Sanders (MSFT)
mercredi 20 juin 2012 14:05Yes, got it working with the Blob sample from the SDK. Not sure if that is the most efficient way though. But fast enough :)
I wonder though, what happens if my app is getting suspended while its in the process of writing to the disk. The file would then be not written (completely) would it?
vendredi 22 juin 2012 10:48Modérateur
>> what happens if my app is getting suspended while its in the process of writing to the disk. The file would then be not written (completely)
When the app is being suspended, you will have several seconds to do whatever you want to save the state. During those several seconds, user cannot interact with UI (as the app is in background), so no new commands will be queued. Usually saving an image file takes less than 1 second. thus it will not be an issue. If you have concern on what if power is suddenly cut, you check if the image on the disk is valid when the next time the app starts. If it’s invalid, you download it from the source and save it to disk again.