sirjo66 Well-Known Member Licensed User Longtime User Nov 4, 2014 #1 I have an app with HTTP server service When the customer ask for a file, the app send this file (is a JPG file) and then the app delete this file on the device. All works fine on many devices, but on a device these lines fault: Code: Copy ' send the file Response.SetContentType("image/jpeg") Response.SendFile(File.DirDefaultExternal, FileNameToSend) ' delete the file File.Delete(File.DirDefaultExternal, FileNameToSend) My image appeare right for the 90% of the image, and the last lineas on image are all grey. This because, while the system is sending the image, it are deleted ! If I delete the line Code: Copy File.Delete(File.DirDefaultExternal, FileNameToSend) it works fine How can I do ? I want to delete the file when the system has finished to send the file, so the file is uploaded right. Many thanks Sergio
I have an app with HTTP server service When the customer ask for a file, the app send this file (is a JPG file) and then the app delete this file on the device. All works fine on many devices, but on a device these lines fault: Code: Copy ' send the file Response.SetContentType("image/jpeg") Response.SendFile(File.DirDefaultExternal, FileNameToSend) ' delete the file File.Delete(File.DirDefaultExternal, FileNameToSend) My image appeare right for the 90% of the image, and the last lineas on image are all grey. This because, while the system is sending the image, it are deleted ! If I delete the line Code: Copy File.Delete(File.DirDefaultExternal, FileNameToSend) it works fine How can I do ? I want to delete the file when the system has finished to send the file, so the file is uploaded right. Many thanks Sergio
DonManfred Expert Licensed User Longtime User Nov 4, 2014 #2 Wait for Jobdone raise and delete the file only if job.success = true. Upvote 0
sirjo66 Well-Known Member Licensed User Longtime User Nov 4, 2014 #3 I'm sorry, I am a newbie I thinked that JobDone is an Event for HTTP client, is it also for HTTP server ?? My code: Code: Copy Private server As HttpServer .... server.Initialize("Server") server.Start(port) .... Sub Server_HandleRequest (Request As ServletRequest, Response As ServletResponse) .... End Sub How can I create event for JobDone ?? But JobDone if only for HttpJob or also for HttpServer ?? Thanks Sergio Upvote 0
I'm sorry, I am a newbie I thinked that JobDone is an Event for HTTP client, is it also for HTTP server ?? My code: Code: Copy Private server As HttpServer .... server.Initialize("Server") server.Start(port) .... Sub Server_HandleRequest (Request As ServletRequest, Response As ServletResponse) .... End Sub How can I create event for JobDone ?? But JobDone if only for HttpJob or also for HttpServer ?? Thanks Sergio
DonManfred Expert Licensed User Longtime User Nov 4, 2014 #4 Sorry! My fault!! I did not read correctly and i dont registrated that you are talking about a SERVER. :-/ You are right; jobDone is used when using httputils Upvote 0
Sorry! My fault!! I did not read correctly and i dont registrated that you are talking about a SERVER. :-/ You are right; jobDone is used when using httputils
Erel B4X founder Staff member Licensed User Longtime User Nov 5, 2014 #5 The file is sent asynchronously after the HandleRequest event. This means that you cannot delete it at that point. You can use a timer to delete the files every x minutes. Upvote 0
The file is sent asynchronously after the HandleRequest event. This means that you cannot delete it at that point. You can use a timer to delete the files every x minutes.
sirjo66 Well-Known Member Licensed User Longtime User Nov 5, 2014 #6 OK, many thanks for the answer. I solved it by changing the protocol (client and server are my programs). Now, the client first send a request for to read the file, read and save it, and then the client send another request for to delete the file. So the server app works right !! Sergio Upvote 0
OK, many thanks for the answer. I solved it by changing the protocol (client and server are my programs). Now, the client first send a request for to read the file, read and save it, and then the client send another request for to delete the file. So the server app works right !! Sergio