1

I'm getting this error:

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>

when I use this code

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

to upload a file to Backblaze. What could I be doing wrong and how can I resolve this?

UPDATE After following the suggestion in the comment, I got this error:

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>

But despite the error, file upload was successful.

metadaddy
  • 4,234
  • 1
  • 22
  • 46
Adefowowe
  • 198
  • 2
  • 14
  • 1
    That's an odd one - B2 is saying that the request body - the photo's data - is smaller than the content length sent in the HTTP header. It's a long shot, but the [only other occurrence of this error that I've seen](https://github.com/weareferal/craft-remote-backup/issues/11#issuecomment-658023204) suggests recreating the bucket and the app key. B2 app keys can contain non-alphanumeric characters, while S3 secret keys never do. If your app key contains a `/` or a `+` then it's possible that this is causing Laravel to sent incorrect data. – metadaddy May 03 '23 at 22:42
  • 1
    Thanks for this @metadaddy, it was helpful. I'm not sure non-alphanumeric characters are the issue here, after creating a new bucket and key I indeed got the file uploaded despite having / in the key. But I got another error message. Despite this error, I still saw the file on my backblaze dashboard but not in my app. – Adefowowe May 05 '23 at 10:14
  • If you can post a new question with the error, I'll take a look. – metadaddy May 05 '23 at 16:36
  • 1
    OK. I'll do that, meanwhile, you may want to provide a response I can mark as the answer, since it resolved this issue. – Adefowowe May 05 '23 at 19:19

1 Answers1

0

That's an odd one - B2 is saying that the request body - the photo's data - is smaller than the content length sent in the HTTP header.

It's a long shot, but the only other occurrence of this error that I've seen suggests recreating the bucket and the app key.

One possible root cause: B2 app keys can contain non-alphanumeric characters, while S3 secret keys never do. If your app key contains a / or a + then it's possible that this is causing Laravel to send incorrect data.

metadaddy
  • 4,234
  • 1
  • 22
  • 46