Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Question: Is there a way one can get information regarding how much of an Object has been downloaded? #68

Closed
NeoAnderson87 opened this issue Jun 3, 2015 · 8 comments

Comments

@NeoAnderson87
Copy link

So we have to show a progress bar for the download of every s3 Object. How can this be achieved? Currently the callback is fired after the async operation has been completed.

@karthiksaligrama
Copy link
Contributor

The SDK doesn't support progress yet. BUt i understand that it can be useful to have it. I'll add it to feature requests for now.

@umeraftab
Copy link

Is there any expected date for the availability of this feature? Actually I'm running out of time.
Else for now, is there any way to get the current downloaded bytes of the object?

@karthiksaligrama
Copy link
Contributor

at the moment we do not have any time line for this feature. If you want to get the current downloaded bytes of the object then you will have to customize the UnityMainthreadDispatcher.cs and have an event handler to send you http progress.

@DaleEmrose
Copy link

Heres my solution for download progress using the S3Example files:

modifying UnityMainThreadDispatcher.cs

//place this above/before public void Awake()
public delegate void MyEventHandler(string foo);
public static event MyEventHandler DownloadProgress;

//place this above/before yield return request.WwwRequest; inside of IEnumerator InvokeRequest(UnityWebRequest request)
if (request.RequestContent == null) { // only show if downloading the file!
    int prevProgress = 0;
    int currentProgress = 0;
    do {
        currentProgress = ((int)Mathf.Ceil (request.WwwRequest.progress*100f));
        if (prevProgress != currentProgress) {                  
            DownloadProgress((currentProgress+"%").ToString());
        }
        prevProgress = currentProgress;
        yield return 0;
    } while (request.WwwRequest.progress < 1);
}

modifying S3Example.cs

//place this inside of void Start()
Amazon.Runtime.Internal.UnityMainThreadDispatcher.DownloadProgress += showDownloadProgress;

//create a new void function
void showDownloadProgress(string input) {
    print (input);
}

Now if I can only figure out why ram is consumed at a ridiculous rate using the GetObjectAsync for larger files... but that's a separate issue...

@umeraftab
Copy link

Thank you DaleEmrose, it will certainly help me.
Yes, I'm also facing this ram consumption issue. Even sometimes my app getd crashed. I'm wondering if there is some remedy to this issue.

@NeoAnderson87
Copy link
Author

I guess i can help with this issue. I also posted an issue regarding this long back (The ram issue). I still can't confirm it , but what i guess is happening is that , GetObjectAsync while downloading an object is expanding the compressed file formats.In my case i was downloading compressed unity asset bundles from s3, but they were getting expanded while downloading and the ram usage shot up. The solution i did was , added by own script to the asset bundle script , which compress the the unity package into a zip , and i'll upload that zip on s3. After downloading the zip via GetObjectAsync , i had a script to unzip it at the runtime. This fixed my ram usage issue.

@PLockhart
Copy link

When queuing a lot of requests, I wanted to keep track of a specific post request. I added code in #107 to add a callback to post requests so you can watch over the web request object, in case anyone finds it useful

@karthiksaligrama
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants