5

I am making a universal application for windows phone 8.1. I want to upload a file to server in background. Microsoft provides BackgroundUploader class which contains BeginUploadAsync method which uploads whole file in a single request in background.

I want to upload file in chunks to the server. But i am not able to find anyway to upload file in chunks. Is there any alternative?

Milan Aggarwal
  • 5,104
  • 3
  • 25
  • 54
abhishekiiit
  • 160
  • 1
  • 10
  • 2
    Why do you care about the file chunks if the uploading is being in background ? – Rohit Prakash Feb 11 '15 at 07:27
  • A larger request is generally more likely to fail, as the capabilities of the device are lower. I'm not familiar with the `BackgroundUploader` class, but I'll assume it has built-in chunking, and that it possibly even gives you some control over it (can you find anything that resembles buffer-size?) – SimpleVar Feb 11 '15 at 07:33
  • @RohitPrakash if larger request fails user data will not be useful and i don't want to waste data – abhishekiiit Feb 11 '15 at 07:47
  • @YoryeNathan No nothing like that. It supports multipart upload but it is not for uploading same file , it is for uploading multiple files in one request... i understand only this from documentation – abhishekiiit Feb 11 '15 at 07:48
  • Is there any standard for uploading files in chunks? I know the background transfer API pretty well, and there is nothing built in like that. Does Android or iOS have uploads in chunks? – kiewic Feb 12 '15 at 20:54
  • @kiewic for android there is no such limitation by OS, the app continues to run in background unlike windows where app processing stops. In IOS there is no such api which helps in chunking , app continues to work for 3 minutes and after that it get killed by OS – abhishekiiit Feb 13 '15 at 07:08
  • Are you saying that in iOS and Android you will have to cut the file in chunks, upload every chunk, retry chunks that fail to upload, and join the chunks at the server? · In that case, in WinRT, you can split your file in chunks, and start multiple uploads. If you don't want to literally cut the file in chunks, you could implement multiple `IInputStream` that read different parts of the file and upload them with `BackgroundUploader.CreateUploadFromStreamAsync()`. Background Transfer will retry multiple times if an upload fails because of network connectivity issues. – kiewic Feb 13 '15 at 18:21
  • @kiewic but it will not solve the problem. What i want is to upload chunks serially, one after other. So that in any case i will lose only one chunk. Suppose user is uploading 100MB file then if he had already uploaded 99MB and connection get killed in last 1 MB transfer , he will not loose all 99 MB but only the last 1 MB. Now with windows i cannot serialize the uploads because i don't have any callback after uploading (in background), so that next is uploaded after first completes. – abhishekiiit Feb 16 '15 at 09:39
  • Yes, you can serialize. You can create 100 chunks, schedule 100 uploads and serialize with `backgroundDownloader.TransferGroup.TransferBehavior = BackgroundTransferBehavior.Serialized`. – kiewic Feb 16 '15 at 22:30
  • @kiewic thanx . i guess this is only thing which i can do . trying it – abhishekiiit Feb 17 '15 at 07:09
  • @kiewic file division is taking a hell lot of time... it is not suitable for windows phone where app can be suspended anytime. Also the serialized behavior does not guarantee file order, it just guarantee one file at a time but the order can be different., so it is increasing server side complication. – abhishekiiit Mar 13 '15 at 12:31
  • You could take a look at the code of this https://silverlightuploader.codeplex.com/ while you can't just use it since' it's silverlight/aspx you should be able to adapt the method it uses to the platforms you are using. – Rhys Bevilaqua Apr 16 '15 at 08:34
  • The solution posed in this question might work to solve your problem: http://stackoverflow.com/questions/23518817/send-byte-array-by-http-post-in-store-app – VulgarBinary May 13 '15 at 00:31

1 Answers1

0

There is no any built-in support for uploading files "chunk by chunk". If you really need to upload files in a such way, you should split file into parts manually and upload them separately.

RavingDev
  • 2,817
  • 1
  • 17
  • 19