How to use URL class to know how many bytes is uploaded?


#1

Hi, all
How are you?
I make use of URL class to do uploading. This uploading process is invisible now. I am going to add a progress bar to indicate how many bytes or percentage has been uploaded in my GUI. Could you please tell me how to acheive this by making use of URL class in juce?

Cheers!
Chengyu


#2

The createInputStream method can take a callback, and that’ll be called to tell you how far it’s got.


#3

Hi, jules
Thanks for your reply. Yes, we can make use of this callback to know the progress updateInfo. I tried to use this in uploadfilethread.

I am confuse about the context pointer in the arg list that OpenStreamProgressCallback() takes.
what’s the meaning and use for context pointer?

I need to do multiple files uploading and get the progress info for each of them. I wonder if context could provide the uploading files’ info, and I can make use of it and differentiate the different progress info.

the function definition is as follows:
typedef bool() URL::OpenStreamProgressCallback(void *context, int bytesSent, int totalBytes)

Thanks!
leon


#4

It’s just a pointer you can fill with any value you want, to provide your callback with some info about the context in which it’s being called.


#5

hi, jules
Thanks for your help!

Cheers!
leon