Hello Paulo, there are several different ways to define a callable detailed in
the PHP documentation <http://php.net/manual/en/language.types.callable.php>.
The one you used allowing you to direct a callback to a method of an
instantiated object, is that the case in your situation?
If it's not and this script isn't part of an object at all you might want
to define your callback as a simple string:
'uploadProgressCallback' => 'uploadProgress'
On Wednesday, July 5, 2017 at 1:48:40 PM UTC-4, Paulo Henrique wrote:
>
> I'm using Gcloud PHP library for uploading files to storage buckets and it
> works fine. But I want to track progress from this upload process, trying
> to use the uploadProgressCallback option provided and documented here:
> https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.33.0/storage/bucket?method=getResumableUploader
>
> But it's not working, the callable isn't fired at all. I'm new to using
> callable functions, but I think it's pretty simple. Here's my code below.
>
> function uploadObject($bucketName, $objectName, $source){
> $storage = new StorageClient();
> $bytes = 0;
> $bucket = $storage->bucket($bucketName);
> $uploader = $bucket->getResumableUploader (
> $file = fopen($source, 'r'),
> [
> 'name' => $objectName,
> 'resumable' => true,
> 'chunkSize' => 524288,
> 'uploadProgressCallback' => array($this, 'uploadProgress')
> ]
> );
>
>
> try {
> $object = $uploader->upload();
>
> } catch ( GoogleException $ex ) {
> $resumeUri = $uploader->getResumeUri();
> $object = $uploader->resume($resumeUri);
> }
> }
> function uploadProgress($bytes) {
>
> $_SESSION['uploadProgress'] = $bytes; }
>
> Any help would be greatly appreciated...
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/a34c4c9f-00c7-4dfa-92d1-46367c325147%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.