Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do i search the file by using file name in the google drive by using this plugin #100

Open
swamyyadav opened this issue Aug 31, 2021 · 2 comments

Comments

@swamyyadav
Copy link

swamyyadav commented Aug 31, 2021

Currently, I'm getting the list files from the folder, I know this will take more time to execute if the folder contains more no.of files.
below is the code snippet, please help me with a solution.

public static function getFileLink($folder_name,$file_name){
        $google_folders = Session::get('google_folders');
        $floder_name = $folder_name;
        $folder_id = $google_folders[$floder_name];
        $files = Storage::disk('google')->allFiles($folder_id);
        $db_file_name = $file_name;
        if(count($files)>0){
            foreach ($files as $file) {
                $firstName = $file;
                $details = Storage::disk('google')->getMetadata($firstName);
            if($details['name']== $db_file_name){
                  return $url = Storage::disk('google')->url($firstName);
            }
          }
        }else{
            return 'No File Found!';
        }
    }
@PaolaRuby
Copy link

PaolaRuby commented Sep 6, 2021

First always use [<>] button for code, second this package doesn' have support, i'm using masbug/flysystem-google-drive-ext wich has the same config but works with paths, only you has to do

Storage::disk('google')->getDriver()->getAdapter()->getMetadata('path/to/your/file.txt');

@swamyyadav
Copy link
Author

swamyyadav commented Oct 11, 2021

Thank you, ill check.

@swamyyadav swamyyadav reopened this Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants