我对Firebase有点困惑。我有一个应用程序,它可以很好地处理Laravel的默认存储。但是我不想让我的用户生成的更多内容出现在我的服务器上,所以我正在考虑使用Firebase云存储服务。但我有点怀疑。
这是我的控制器功能,当我收到图像文件时,它会上传到Laravel上的服务器:
if($request->hasFile('file')) {
$mpFile = $request->file('file');
$date = Carbon::now();
$year = $date->year;
$month = $date->month;
$directory = $year . '/' . $month;
$fileObj['filepath'] = Storage::disk('uploads')->put($directory, $mpFile);
$fileObj['fileName'] = basename($fileObj['filepath']);
$exists = Storage::disk('uploads')->exists($fileObj['filepath']);
if($exists) {
$this->mdFile->store($fileObj, $categoryObj->mp_category_id);
$response["imgstatus"] = "Imagem anexada com sucesso";
}else {
$response["imgstatus"] = "Não foi possível fazer o upload tente novamente";
}
}当发生这种情况时,我会将file_path和file_name与数据库上的对象ID引用相关联地存储在数据库中。
但是我不知道我如何使用Firebase,我必须使用Laravel上的Firebase吗?要存储图像并从Firebase接收file_path和file_name?我是怎么做到的?
还是只是另一种方法?
发布于 2019-12-27 15:56:01
检查这个文档https://firebase.google.com/docs/storage/web/upload-files
您可以上传图片到防火墙存储,并获得下载URL作为回报。可以将此路径保存在所使用的数据库中。
在这个链接中有很好的教程:https://angularfirebase.com/lessons/firebase-storage-with-angularfire-dropzone-file-uploader/
https://stackoverflow.com/questions/59502799
复制相似问题