I'm using Laravel 5.4. I'm trying to upload file to google drive using
Storage::disk('google')->put('file.txt', 'hello world')
using above method file named 'file.txt' is created in Google Drive folder. but i have to upload an existing zip file.
I'm using the below code to upload the zip file in google drive.
Storage::disk('google')->put('RandomFileName.zip', storage_path('app/backup.zip'));
Zip file is created but with corrupted file having size in 50 byte sometimes.
As per the documentation for Laravel File Storage you should use the copy
or move
method, not put
.
So your code should be something like:
Storage::disk('google')->move(storage_path('app/backup.zip'), 'RandomFileName.zip');
I've solved this issue by
Storage::disk('google')->put('FileName.zip', file_get_contents("fileLocation"));
Previously I was not including file_get_contents() that's why it wasn't including the content of the zip file.