Android Download Manager response message - android

I am trying to download a file using DownloadManager, but I have a few scenarios to make decision on download response.
How to get success response message from download manager?

Related

Upload file & download a file in response using volley

I would like to upload one file on server through android device. Once the file is uploaded on server it modifies it & sent back to client.
Can you please help how to achieve it through volley in request I have to upload the file & in response am getting a file after applying some modification on uploaded file. After getting the file in response need to save it in mobile device.
Got one example from Github in which a file was uploaded on server through SimpleMultiPartRequest class but in response was getting string response. In my case am getting status as success or failure along with the modified file.

The Android Download Manager api failed to download ("Unsuccessful download")

In some occasions, when trying to download a file with the Android DownloadManager, the download failed and the download notification shows "Unsuccessful download".
After some hours of debugging, I realized some of the headers that I was passing to the download manager were null or empty. Especially the "User-Agent", when that happens the download manager posts a notification saying "Unsuccessful download".
val androidDownloadManager = applicationContext.getSystemService(DOWNLOAD_SERVICE) as AndroidDownloadManager
val request = Request(Uri.parse(download.url))
request.addRequestHeader("User-Agent", download.userAgent)
androidDownloadManager.enqueue(request)

Unable to download files from cordova app

I am facing an issue with trying to download a file from the server in the cordova android app...In the cordova app we are using the inappbrowser to open a web application in html and JS. When we try to do window.open("url","_blank") we are unable to get the file to be downloaded.
From the server we are getting
Content-Disposition: attachment; filename="filename.jpg"
Still i am unable to get the files to get downloaded
Response headers have the content disposition set and the response seems to be empty with a content type text/file
One concern for us is that the cookies need to be sent alongside with the request and is set by the server after authentication, hence we cannot use the external browser (using _system)
Thanks

Pushbullet + WebClient = download only body content from note notification

This is my first attempt to use the Pushbullet API to read the latest notification sent.
I have successfully authenticated my WebClient and upload/download its last push, but I want to download only the body (note's message) from the push of note type. If you guys take a look at the example bellow, the WebClient.DownloadString brings not only the body, but also every information available from the push.
Is there a way to download only the note's message, and not everything from it?
wc.DownloadString("https://api.pushbullet.com/v2/pushes?limit=1");
Result:
"{\"accounts\":[],\"blocks\":[],\"channels\":[],\"chats\":[],\"clients\":[],\"contacts\":[],\"devices\":[],\"grants\":[],\"pushes\":[{\"active\":true,\"iden\":\"ujCch9rXhnwsjAvxQ1EFi0\",\"created\":1.454030974949465e+09,\"modified\":1.454031099564189e+09,\"type\":\"note\",\"dismissed\":true,\"direction\":\"self\",\"sender_iden\":\"ujCch9rXhnw\",\"sender_email\":\"xx#gmail.com\",\"sender_email_normalized\":\"xx#gmail.com\",\"sender_name\":\"ABC\",\"receiver_iden\":\"ujCch9rXhnw\",\"receiver_email\":\"x#gmail.com\",\"receiver_email_normalized\":\"xx#gmail.com\",\"title\":\"abc\",\"body\":\"test line 1\r\ntest line 2\r\ntest line
3\"}],\"profiles\":[],\"subscriptions\":[],\"texts\":[],\"cursor\":\"eyJWZXJzaW9uIjoxLCJNb2RpZmllZEFmdGVyIjoiMDAwMS0wMS0wMVQwMDowMDowMFoiLCJNb2RpZmllZEJlZm9yZSI6IjIwMTYtMDEtMjlUMDE6MzE6MzkuNTY0MTg5WiJ9\"}"
In the API, no. The easiest way is to parse the response with a JSON parser and get response["pushes"][0]["body"]

Getting server response from DownloadManager

My application downloads files using Android DownloadManager. If download is failed for some reason (for example file doesn't exists anymore) my server provides me with XML response containing problem description. But it seems that in ACTION_DOWNLOAD_COMPLETE receiver I can only get HTTP status code.
My question is: Can I actually somehow get XML server response (or just raw response) in ACTION_DOWNLOAD_COMPLETE receiver?
For now I can see only variant with sending extra request if download is failed.

Categories

Resources