Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

上传云存储,会报错 #6

Closed
z-perfe opened this issue Apr 28, 2022 · 10 comments
Closed

上传云存储,会报错 #6

z-perfe opened this issue Apr 28, 2022 · 10 comments

Comments

@z-perfe
Copy link

z-perfe commented Apr 28, 2022

在CroppingController文件中,有这么一句
$filename = Storage::disk(config('admin.upload.disk'))->putFile('weiwait/cropper', $request->file('file'));
然后上传云存储,
在 Cropping.php中
} elseif (str_starts_with($file, 'weiwait/cropper')) { $storage = Storage::disk(config('admin.upload.disk')); $cached = $storage->get($file); //...... }
文件提示找不到,只好把整段ELSE删除。
看这段 else 是上传 weiwait 的临时文件然后删除吗? 那为何不直接在 controller 中
$filename = Storage::disk(config('admin.upload.disk'))->putFile(config('admin.upload.directory.image'), $request->file('file'));

@weiwait
Copy link
Owner

weiwait commented Apr 28, 2022

你追踪下文件存放,找找问题所在。controller中返回的是临时文件,表单提交后复制临时文件到长久保存目录,所以是在Cropping.php中进行

@z-perfe
Copy link
Author

z-perfe commented Apr 28, 2022

跟踪过了,报错的原因
Storage::disk(config('admin.upload.disk'))->putFile('weiwait/cropper', $request->file('file'));
是直接提交到云存储
但是
$cached = $storage->get($file);
这里没有带域名,是 weiwait/cropper/...image
所以报错。

@weiwait
Copy link
Owner

weiwait commented Apr 28, 2022

跟踪过了,报错的原因 Storage::disk(config('admin.upload.disk'))->putFile('weiwait/cropper', $request->file('file')); 是直接提交到云存储 但是 $cached = $storage->get($file); 这里没有带域名,是 weiwait/cropper/...image 所以报错。

你的admin的上传配置是怎么样的

@z-perfe
Copy link
Author

z-perfe commented Apr 28, 2022

admin.php 配置是上传云的。所以 CroppingController.php 中直接上传到云存储,prepareInputValue() 函数应该都不用复写了。不过我本地没发现调用 CroppingController.php ,还是BASE64,但服务器是直接调用了。

@weiwait
Copy link
Owner

weiwait commented Apr 28, 2022

你测试过了本地可以?

@z-perfe
Copy link
Author

z-perfe commented Apr 28, 2022

我没有看前端代码,觉得裁切后,直接AJAX调用 CroppingController.php 上传,返回文件地址后就无需任何处理了。我现在本地走的
if (preg_match('/^(data:\s*image/(\w+);base64,)/', $file, $result)){

服务器值是云存储的地址,就没有做任何处理 (else的代码删掉了)

@weiwait
Copy link
Owner

weiwait commented Apr 28, 2022

我没有看前端代码,觉得裁切后,直接AJAX调用 CroppingController.php 上传,返回文件地址后就无需任何处理了。我现在本地走的 if (preg_match('/^(data:\s*image/(\w+);base64,)/', $file, $result)){

服务器值是云存储的地址,就没有做任何处理 (else的代码删掉了)

刚才是了下,云存储也没有问题

@weiwait
Copy link
Owner

weiwait commented Apr 28, 2022

我没有看前端代码,觉得裁切后,直接AJAX调用 CroppingController.php 上传,返回文件地址后就无需任何处理了。我现在本地走的 if (preg_match('/^(data:\s*image/(\w+);base64,)/', $file, $result)){

服务器值是云存储的地址,就没有做任何处理 (else的代码删掉了)

你检查下云存储的配置

@weiwait
Copy link
Owner

weiwait commented Apr 28, 2022

我没有看前端代码,觉得裁切后,直接AJAX调用 CroppingController.php 上传,返回文件地址后就无需任何处理了。我现在本地走的 if (preg_match('/^(data:\s*image/(\w+);base64,)/', $file, $result)){

服务器值是云存储的地址,就没有做任何处理 (else的代码删掉了)

你有加入dcat-admin的qq或者微信的话可以在里面找我

@z-perfe
Copy link
Author

z-perfe commented Apr 28, 2022

一群已经满了,可加我Q 9816396 啊

@weiwait weiwait closed this as completed May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants