简体   繁体   English

使用Laravel中的REST API将大文件上传到Amazon S3

[英]Uploading large files with REST api in Laravel to Amazon S3

I'm trying to upload videos to an Amazon S3 bucket through my Laravel API. 我正在尝试通过Laravel API将视频上传到Amazon S3存储桶。 I'm using the Laravel filesystem, and using: 我正在使用Laravel文件系统,并使用:

Storage::getDriver()
         ->putStream('videos/' . $fileName . '.' . $ext, fopen($file, 'r+'));

It works perfectly for mp4 files of 1Mb, but when i try to upload something like 30Mb mp4 file, it takes about 3 minutes, and it doesn't succeed. 它非常适合1Mb的mp4文件,但是当我尝试上传类似30Mb的mp4文件时,大约需要3分钟,但未成功。

I use Postman to send the request POST http://localhost:8000/api/videos with Content-Type: form-data. 我使用Postman发送带有Content-Type:form-data的请求POST http:// localhost:8000 / api / videos

Does anyone have an idea? 有人有主意吗?

I found that the solution to the problem was to set a higher value for "upload_max_filesize" and "post_max_size" in my php.ini file. 我发现解决该问题的方法是在我的php.ini文件中为“ upload_max_filesize”和“ post_max_size”设置更高的值。 Now it works perfectly. 现在,它可以完美运行了。

Firstly: find the "php.ini" file (/etc/php/7.2/cli/php.ini) and open it by root (sudo) 首先:找到“ php.ini”文件(/etc/php/7.2/cli/php.ini)并通过root(sudo)打开

Secondly: change post_max_size=50M and upload_max_filesize=50M (in your case just need to change upload_max_filesize). 其次:更改post_max_size = 50M和upload_max_filesize = 50M(在您的情况下,只需更改upload_max_filesize)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM