5

I'm using BackgroundTransferRequest in WP8 application for uploading a file to my server. The server receives the file and send a response back with some useful info regarding uploaded file. How can I get this info?

It seems there's no API for that (shamely). Probably, I'm missing something.

Note that request.BytesReceived property returns 99 bytes, looks like request knows that some data is returned from server, but I've no idea how to get it.

Stas Shusha
  • 528
  • 3
  • 11

2 Answers2

1

With the great help of Eric Fleck form MSFT we found out that adding DownloadLocation and Method="Post" properties making response to be written in DownloadLocation file. So the valid request is:

var request = new BackgroundTransferRequest(targetUri)
    {
        DownloadLocation = new Uri(downloadTo, UriKind.Relative),
        UploadLocation = new Uri(uploadFrom, UriKind.Relative),
        Method = "POST"
    };
Stas Shusha
  • 528
  • 3
  • 11
  • shusha hi, I'm having the same situation as yours. server returns some jSon data after file upload successfully. I want to get that data. here as you said, I saw that `BackgroundTransferRequest` shows that `BytesReceived`. here I tried by assign `DownloadLocation` to get that data. but somehow it seems like Downloaded data is not copying into the file in IsolatedStorage `Shared/Transfers` folder. Plz guide me further if possible.. – Keval Langalia Apr 27 '15 at 11:24
  • @KevalLangalia make sure you actually have `/shared/transfers` part in your paths – Stas Shusha May 04 '15 at 16:45
  • I detected the issue. it was of unSuccessful request i resolved it and got the response. Thanks for your efforts.. :) – Keval Langalia May 05 '15 at 04:44
0

It appears that there are two events you can subscribe to, TransferStatusChanged and TransferProgressChanged (see MSDN BackgroundTransferRequest page). Would these provide the information you're looking for?

There is also an example "How to implement background file transfers for Windows Phone" that shows a way to display transfer information for multiple transfers.

Jedidja
  • 16,610
  • 17
  • 73
  • 112
  • I've already studied each and every line in MSDN regarding Background Transfers in WP8 - there's nothing helpful for my question. Also those events have nothing to do with uploading result as their names state. – Stas Shusha Oct 27 '13 at 10:12
  • I must have misunderstood your question. What is this "useful info" that is sent back? Did you grab the response from Fiddler or something similar? – Jedidja Oct 28 '13 at 22:38
  • In the response to my POST upload request server returns and Id of the file. I have an implementation for this using `HttpClient` and its API allows to read the response content, but I want to use `BackgroundTransferService` instead. – Stas Shusha Oct 29 '13 at 12:35