Upload a document using Zend gdata

490 Views Asked by At

I'm trying to upload a simple csv document to google docs using zend gdata library but somehow it gets stuck.

I've looked all files used for upload and found where it gets stuck:

On line: 229 of Zend/Gdata/Docs.php after: $fs = $this->newMediaFileSource($fileLocation);

I couldn't find that newMediaFileSource() function even though I've looked at every-single file. Anyone has an idea on how can I resolve this?

public function uploadFile($fileLocation, $title=NULL, $mimeType=NULL, $uri=NULL)
    {
        // Set the URI to which the file will be uploaded.
        if ($uri === NULL) {
            $uri = $this->_defaultPostUri;
        }
        // Right after this line it stops executing:
        $fs = $this->newMediaFileSource($fileLocation);
        if ($title !== NULL) {
            $slugHeader = $title;
        } else {
            $slugHeader = $fileLocation;
        }
1

There are 1 best solutions below

0
On

I have a similar problem to you. I couldn't find the function either so i suspected it's using a magic php call and sure enough in Zend_Gdata_App round line 1041:

public function __call($method, $args)
{
    if (preg_match('/^new(\w+)/', $method, $matches)) {
        $class = $matches[1];
        $foundClassName = null;
        foreach ($this->_registeredPackages as $name) {
             try {
                 // Autoloading disabled on next line for compatibility
                 // with magic factories. See ZF-6660.
                 if (!class_exists($name . '_' . $class, false)) {
                    require_once 'Zend/Loader.php';
                    @Zend_Loader::loadClass($name . '_' . $class);
                 }
                 $foundClassName = $name . '_' . $class;
                 break;
             } catch (Zend_Exception $e) {
                 // package wasn't here- continue searching
             }
        }

     ....
}

its basically parsing the method name to check if there are any packages after "new"

its basically creating an object of type Zend_Gdata_App_MediaFileSource