使用 php Laravel 将文件存储到 s3 存储桶
Store file to s3 bucket using php Laravel
我想根据文件的目录将文件存储在 s3 中,但是当我执行此代码时,它会将字符串 "storage / ;;;" 保存在文件中,而不是包含其内容的 docx??
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx";
Storage::disk('s3')->put("fusiondoc/doc",$path,'public');
我还通过添加 Storage :: get 使用此代码进行了测试,但它不起作用??谢谢uu
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx";
$content = Storage::get($path);
$full_path = Storage::disk('s3')->put("fusiondoc/doc",$content,'public');
第二个参数是内容不是路径,所以这样更新
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx";
Storage::disk('s3')->put("fusiondoc/doc/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx",fopen($path),'public');
评论更新
$fileName = uniqid () . Str::afterLast($path,".");
Storage::disk('s3')->put("fusiondoc/doc/" . $fileName,fopen($path),'public');
我想根据文件的目录将文件存储在 s3 中,但是当我执行此代码时,它会将字符串 "storage / ;;;" 保存在文件中,而不是包含其内容的 docx??
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx";
Storage::disk('s3')->put("fusiondoc/doc",$path,'public');
我还通过添加 Storage :: get 使用此代码进行了测试,但它不起作用??谢谢uu
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx";
$content = Storage::get($path);
$full_path = Storage::disk('s3')->put("fusiondoc/doc",$content,'public');
第二个参数是内容不是路径,所以这样更新
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx";
Storage::disk('s3')->put("fusiondoc/doc/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx",fopen($path),'public');
评论更新
$fileName = uniqid () . Str::afterLast($path,".");
Storage::disk('s3')->put("fusiondoc/doc/" . $fileName,fopen($path),'public');