简体   繁体   English

如何将文件从流明存储文件夹复制到laravel存储

[英]How to copy file from lumen storage folder to laravel storage

i need one help , I couldn't figure out solution for this for copying file from lumen storage folder to laravel storage folder. 我需要一个帮助,我无法解决将文件从流明存储文件夹复制到laravel存储文件夹的解决方案。 As I have app whose api I'm doing with lumen and web part with Laravel. 因为我有应用程序的API,所以我正在使用Laravel处理流明和Web部件。 One of my api is used to upload file , which I'm storing it in lumen storage folder but I have planned to make a copy of it to Laravel storage folder and unlink the one from Lumen . 我的一个api用于上传文件,我将其存储在lumen存储文件夹中,但我计划将其复制到Laravel存储文件夹中,并与Lumen取消链接。

I have used this code given below in Lumen , but its not working . 我已经使用了下面在Lumen中给出的代码,但是它不起作用。

Storage::put($filename,  File::get($file));
$mkcopy_src=Storage::copy($filename, '/data/html/xyzapi/storage/app/public/media/'.$filename);

These aren't the answers you're going to like. 这些不是您想要的答案。

1. Fix your design 1.修正您的设计

Your two applications shouldn't be able to talk to each other at a server level. 您的两个应用程序应该不能在服务器级别相互通信。 This breaks the API design you've created. 这会破坏您创建的API设计。

By introducing /data/html/xyzapi/ , you're also making it server dependant, which means that the app is no longer portable. 通过引入/data/html/xyzapi/ ,您还使它依赖于服务器,这意味着该应用程序不再可移植。

If you need to transfer something from the API to the app, then I would use an internal API to do that. 如果您需要将某些东西从API转移到应用程序,那么我将使用内部API来做到这一点。 It's safer and more scalable. 它更安全,更可扩展。 Create end endpoint on the app that will accept the file from the API. 在应用程序上创建最终端点,该端点将接受来自API的文件。

However... 然而...

2. Don't store in storage 2.不要储存

Storage is only for application storage. 存储仅用于应用程序存储。 At any given time I should be able to delete the contents of your storage folder and your app can recover. 在任何给定时间,我都应该能够删除您的存储文件夹中的内容,并且您的应用程序可以恢复。 (I know that you can link the public folder to storage, but that was not designed for saving user-uploaded files.) (我知道您可以将公用文件夹链接到存储,但这不是用于保存用户上传的文件的。)

Instead, consider using a cloud service such as Coudinary or one that comes with your host. 相反,请考虑使用诸如Coudinary之类的云服务或主机随附的云服务。

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

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