laravel-google-drive-demo
laravel-google-drive-demo copied to clipboard
uploding multiple files fails
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++;
}
Is $d->dir the folder ID?
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.
https://github.com/masbug/flysystem-google-drive-ext avoids creating new paths individually