【问题标题】:Error while uploading existing file to google drive using Laravel 5.4使用 Laravel 5.4 将现有文件上传到谷歌驱动器时出错
【发布时间】:2017-11-17 10:27:01
【问题描述】:

我正在使用 Laravel 5.4。我正在尝试使用

将文件上传到谷歌驱动器

Storage::disk('google')->put('file.txt', 'hello world')

使用上述方法在 Google Drive 文件夹中创建名为“file.txt”的文件。但我必须上传现有的 zip 文件。

我正在使用下面的代码将 zip 文件上传到谷歌驱动器中。

Storage::disk('google')->put('RandomFileName.zip', storage_path('app/backup.zip'));

Zip 文件已创建,但有时损坏的文件大小为 50 字节。

【问题讨论】:

  • 我想上传文件到谷歌驱动有什么办法吗?

标签: php laravel laravel-5 database-backups


【解决方案1】:

我已经解决了这个问题

Storage::disk('google')->put('FileName.zip', file_get_contents("fileLocation"));

之前我没有包含 file_get_contents(),所以它没有包含 zip 文件的内容。

【讨论】:

    【解决方案2】:

    根据Laravel File Storage 的文档,您应该使用copymove 方法,而不是put

    所以你的代码应该是这样的:

    Storage::disk('google')->move(storage_path('app/backup.zip'), 'RandomFileName.zip');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多