Поместите файл в подпапку, чтобы google drive использовал laravel - PullRequest
0 голосов
/ 16 января 2019

У меня проблемы с кодом для загрузки файлов на диск Google, когда я использую пакет nao-pon/flysystem-google-drive, этот код будет создан text.txt to subdirectory = "Contract", но у меня много папок с разными именами, и они являютсяТе же 2 папки Дети: Контракт, Проект.Я не могу найти способ создать text.txt в нужном имени папки

Я пытался исправить запрос в

$dir = $contents->where('type', '=', 'dir')
    ->where('filename', '=', 'Contract')
    ->first();

, но он не работает.

    Route::get('put-in-dir', function() {
$dir = '/';
$recursive = true; // Get subdirectories also?
$contents = collect(Storage::cloud()->listContents($dir, $recursive));

$dir = $contents->where('type', '=', 'dir')
    ->where('filename', '=', 'Contract')
    ->first(); // There could be duplicate directory names!

if ( ! $dir) {
    return 'Directory does not exist!';
}

Storage::cloud()->put($dir['path'].'/test.txt', 'Hello World');

return 'File was created in the sub directory in Google Drive';
});

Я хочу создать text.txt в Forder, я хочу.Пример: я хочу создать в контракте Ясуо ..

Shaco-
  --Contract
  --Project
Yasuo-
  --Contract
  --Project

1 Ответ

0 голосов
/ 16 января 2019

я нашел решение.Это мое решение:

Route::get('put-in-dir', function() {
$content = collect(Storage::cloud()->listContents('/', false));
    foreach ($content as $key => $value) {
        if($value['name'] == 'MrTrung')
            $root = $value['path'];
    }
    //dd($root);
$dir = '/'.$root;
$recursive = true; // Get subdirectories also?
$contents = collect(Storage::cloud()->listContents($dir, $recursive));

$dir = $contents->where('type', '=', 'dir')
    ->where('filename', '=', 'Contract')
    ->first(); // There could be duplicate directory names!
if ( ! $dir) {
    return 'Directory does not exist!';
}
Storage::cloud()->put($dir['path'].'/test.txt', 'Hello World');
return 'File was created in the sub directory in Google Drive';
});

Примечание: все правильно, когда вы устанавливаете Google Drive API v3.И я иду по этому пути: https://gist.github.com/ivanvermeyen/cc7c59c185daad9d4e7cb8c661d7b89b

удачи.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...