laravel-google-drive-demo icon indicating copy to clipboard operation
laravel-google-drive-demo copied to clipboard

uploding multiple files fails

Open sujith2014 opened this issue 6 years ago • 3 comments
trafficstars

only first file is uploded but return true for `dump($file)


foreach($data as $d) {
                $filename = $d->dir . '/' . $d->name;
                $file = Storage::cloud()->put($filename, $d->content);
                dump($file);
  }

then i change the code for ignoring the first file, then the second file uploded. remaining files not uploded

  $i = 1;
 foreach ($data as $d) {

            if ($i > 1) {
                $filename = $d->dir . '/' . $d->name;
                $file = Storage::cloud()->put($filename, $d->content);
                dump($file);
            }
            $i++;

    }

sujith2014 avatar Feb 14 '19 12:02 sujith2014

Is $d->dir the folder ID?

ivanvermeyen avatar Feb 16 '19 10:02 ivanvermeyen

No directory path

$contents = collect(Storage::cloud()->listContents($d->dir, $recursive));

            $file = $contents
                ->where('type', '=', 'file')
                ->where('filename', '=', pathinfo($d->name, PATHINFO_FILENAME))
                ->where('extension', '=', pathinfo($d->name, PATHINFO_EXTENSION))
                ->first(); 

Instead of searching all the directory. I just pass the directory path and it works if the directory path is not changed. I have 3 types of files thumbnail, medium, large so I created 3 folders. During file upload pass each folder's path, one after the other. only the first one is uploaded. but each path worked individually. Thank you for your response.

sujith2014 avatar Feb 16 '19 10:02 sujith2014

https://github.com/masbug/flysystem-google-drive-ext avoids creating new paths individually

PaolaRuby avatar Dec 27 '21 14:12 PaolaRuby