我收到了这个错误:

Unable to write file at location: profile-photos/rFfDwnJUhtTlcy87bDur4Co7q6UnDYEGRbdl6Bi0.jpg. Error executing "PutObject" on "https://xxx.s3.us-west-004.backblazeb2.com/profile-photos/rFfDwnJUhtTlcy87bDur4Co7q6UnDYEGRbdl6Bi0.jpg"; 
AWS HTTP error: Client error: `PUT https://xxx.s3.us-west-004.backblazeb2.com/profile-photos/rFfDwnJUhtTlcy87bDur4Co7q6UnDYEGRbdl6Bi0.jpg` resulted in a `400 Bad Request` response: 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<Error> 
  <Code>InvalidRequest</Code> 
  <Message>The request (truncated...) 
InvalidRequest (client): The request body was too small - 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<Error> 
  <Code>InvalidRequest</Code> 
  <Message>The request body was too small</Message> 
</Error>

当我使用这个代码时

Storage::disk('s3')->put('profile-photos', $photo);

将文件上传到Backblaze.我可能做错了什么,我该如何解决这个问题?

更新 在遵循了 comments 中的建议后,我得到了这个错误:

Unable to write file at location: profile-photos/0Oafj0VpwBbrMtvgLEnBmGl3UsL4rrUaD7HLzRDA.jpg. Error executing "PutObject" on "https://xxx.s3.us-west-004.backblazeb2.com/profile-photos/0Oafj0VpwBbrMtvgLEnBmGl3UsL4rrUaD7HLzRDA.jpg"; AWS HTTP error: Client error: `PUT https://xxx.s3.us-west-004.backblazeb2.com/profile-photos/0Oafj0VpwBbrMtvgLEnBmGl3UsL4rrUaD7HLzRDA.jpg` resulted in a `400 Bad Request` response: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Error> <Code>InvalidArgument</Code> <Message>Unsupporte (truncated...) InvalidArgument (client): Unsupported value for canned acl 'private' - <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Error> <Code>InvalidArgument</Code> <Message>Unsupported value for canned acl 'private'</Message> </Error>

但尽管出现了错误,文件上传还是成功的.

推荐答案

这是一个奇怪的问题--B2说请求正文--照片的数据--比在HTTP头中发送的内容长度要小.

可能性很小,但the only other occurrence of this error that I've seen人建议重新创建水桶和应用程序密钥.

一个可能的根本原因是:B2应用程序密钥可以包含非字母数字字符,而S3密钥永远不会.如果您的应用程序密钥包含/+,则这可能是导致Laravel发送错误数据的原因.

Laravel相关问答推荐

自定义验证在表单请求上始终返回 true laravel

Vue 组件中的图像不适用于 Vite + Laravel

如何返回Blade Laravel 中的按钮?

Laravel 9 上的数组差异助手

如何避免谷歌翻译翻译:参数

Laravel 有Many Many to Many To One Eloquent

Lumen和 MongoDB?

升级到 laravel 5.4 后调用未定义的方法

eloquent的搜索/自定义属性的位置

如何处理 laravel 5 中的私有图像?

如何在 laravel 中解码 Json 对象并在 laravel 中应用 foreach 循环

使用 Laravel 将两个模型合并到一个分页查询中,并带有Eager加载的关系

如何将对象(模型类型对象)插入到 Laravel 中特定索引号的集合对象中?

如何在 laravel 中使用 GROUP_CONCAT

如何在 Laravel 或 Redis 中取消排队的作业(job)

如何在 Laravel 4 中组织不同版本的 REST API 控制器?

laravel 如何读取 app/config/app.php 调试变量

Laravel 4 - 一个表单中有两个提交按钮,并且两个提交都由不同的操作处理

无法在控制器的构造函数上调用 Auth::user()

如何在没有日志(log)、没有信息的情况下调试 Laravel 错误 500