Giter Club home page Giter Club logo

Comments (7)

acpadhi avatar acpadhi commented on May 9, 2024

google-api-php-client-1.0.0-alpha does not have this problem. Upload Traffic Size is almost equal to file size.

So some issue cropped up after the gzip stuff was added

from google-api-php-client.

ianbarber avatar ianbarber commented on May 9, 2024

Very odd, I can see the same thing when uploading to drive. Disabling the gzip seems to bring it back to normal, which is rather confusing. I'll poke around a little more, but we may just need to automatically disable gzip for file upload, which is straightforward.

Workaround is to disable it manually using: $client->setClassConfig("Google_Http_Request", "disable_gzip", true);

from google-api-php-client.

ianbarber avatar ianbarber commented on May 9, 2024

So what I can see is compress.zlib doing an absolute tonne of writes on the upload, which is not very helpful. Unfortunately, I can't find a wonderful work around that lets us deal with the stream filter in a decent way, so I think disabling on uploads will be the best bet.

from google-api-php-client.

ianbarber avatar ianbarber commented on May 9, 2024

Patched in #65

from google-api-php-client.

AdamWill avatar AdamWill commented on May 9, 2024

I'm seeing something very like this with ownCloud's Google Drive support (which I'm still working to get ported to 1.x). It's using extremely simple upload code, ripped straight from the examples:

public function writeBack($tmpFile) {
    if (isset(self::$tempFiles[$tmpFile])) {
        $path = self::$tempFiles[$tmpFile];
        $parentFolder = $this->getDriveFile(dirname($path));
        if ($parentFolder) {
            // TODO Research resumable upload
            $mimetype = \OC_Helper::getMimeType($tmpFile);
            $data = file_get_contents($tmpFile);
            $params = array(
                'data' => $data,
                'mimeType' => $mimetype,
                'uploadType' => 'media'
            );
            $result = false;
            if ($this->file_exists($path)) {
                $file = $this->getDriveFile($path);
                $result = $this->service->files->update($file->getId(), $file, $params);
            } else {
                $file = new \Google_Service_Drive_DriveFile();
                $file->setTitle(basename($path));
                $file->setMimeType($mimetype);
                $parent = new \Google_Service_Drive_ParentReference();
                $parent->setId($parentFolder->getId());
                $file->setParents(array($parent));
                $result = $this->service->files->insert($file, $params);
            }
            if ($result) {
                $this->setDriveFile($path, $result);
            }
        }
        unlink($tmpFile);
    }
}

and I'm currently testing with version 1.0.6 of the library. But I seem to be seeing just the same issue as the OP here - uploading a simple ~4MB file results in over 100MB of traffic. Any ideas?

from google-api-php-client.

AdamWill avatar AdamWill commented on May 9, 2024

Ah. I think the fix for this may have only fixed it for use of the Google_Http_MediaFileUpload class, not the simple files->insert method. Let me see if my theory holds up.

from google-api-php-client.

AdamWill avatar AdamWill commented on May 9, 2024

Hum. Actually, I think I was using a packaged copy of 1.0.3 I had lying around and somehow with 1.0.6 the problem doesn't happen any more, though I can't clearly see why it would affect 1.0.3 but not 1.0.6. But hey, so long as it works...hey ho.

Aha! So I think I'm not hitting it in 1.0.6 because it's using Curl instead of Stream and bypassing the whole thing. If I force use of Stream instead of Curl, I can cause it to happen again.

In MediaFileUpload.php , the bit where it conditionally disables gzip for uploads is only in nextChunk(), which is only used for resumable uploads. I've tried copying it into process() (with the obvious change to $this->request instead of $httpRequest), and the code gets hit (I put a debug log in to check), but it doesn't seem to do the job - the amount of data transferred is still huge. But if I disable gzip with the big hammer - $client->setClassConfig("Google_Http_Request", "disable_gzip", true); - that does solve the problem. Not quite sure why just trying to disable it in process() doesn't work.

from google-api-php-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.