How do I determine download and upload progress by using spray-client?

236 views
Skip to first unread message

Adrian Rodriguez

unread,
Oct 17, 2013, 3:50:13 PM10/17/13
to spray...@googlegroups.com
Hi everyone,
     Our API kicks off some Actor that 1) downloads a file from a remote service and then uploads it to Joyent's Manta service. Everything works fine, but I wanted to see how I would go about getting the progress in terms of bytesDownloaded/totalBytes so I can display a percentage progress. It may be the lack of sleep, but I just can't find a way to do it. All I really have is the onComplete which will give me the buffer as an Array[Byte]. Is there something in the pipeline I could use to determine the number bytes received as they come in/the number of bytes sent as they go out? 

Any pointers would be great. 

Thanks and congrats to the spray team on the acquisition. With typesafe backing this, maybe they can finally put some pressure on Jetbrains/Intellij IDEA product to fix their god awful scala plugin that uses 400% cpu whenever I open a file with any spray-routing code ;). 

<adrian /> 

Mathias Doenitz

unread,
Oct 18, 2013, 3:24:29 PM10/18/13
to spray...@googlegroups.com
Adrian,

the only way that you can run custom logic upon reception of a new network packet is by setting the
`spray.can.client.parsing.incoming-auto-chunking-threshold-size` setting and using spray-can directly.
This way you can write an actor that uses the spray-can host-level API (for example) to download the file and receive incoming packets right away as `MessageChunk` instances.

As of now spray-client doesn't support chunked responses, which means that your spray-client-level code will only see the HttpResponse instance when the response has been received in its entirety, which makes the implementation of a progress meter impossible.

Cheers,
Mathias

---
mat...@spray.io
http://spray.io
> --
> You received this message because you are subscribed to the Google Groups "spray-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to spray-user+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Adrian Rodriguez

unread,
Oct 19, 2013, 9:54:00 PM10/19/13
to spray...@googlegroups.com, spray...@googlegroups.com
Mathias,
     Thank you for the insight. I'll give it a try. Just out of curiosity, will this type of functionality eventually be exposed in the request level API ?

Sent from Mailbox for iPhone

Mathias Doenitz

unread,
Oct 20, 2013, 4:56:19 PM10/20/13
to spray...@googlegroups.com
Adrian,

since the request-level API builds upon the host-level API it is already available.

Cheers,
Mathias

---
mat...@spray.io
http://spray.io

smiti sharma

unread,
Jun 13, 2016, 10:04:26 AM6/13/16
to spray.io User List
Hello Adrian,

I am trying to download a file from a remote api. Trying to call a GET api which returns me following :
------WebKitFormBoundarywngSDbFerTQNlflG
Content-Disposition: form-data; name="file"; filename="Ola Circle - Users.csv"
Content-Type: text/csv

csv file content. 

Can you please help here 

Thanks
Smiti 
Reply all
Reply to author
Forward
0 new messages