Cms: Asset upload (to S3) only works outside of root

Created on 11 Dec 2019  路  2Comments  路  Source: statamic/cms

v3.0.0-beta.6

Trying to upload assets to S3, but it only works when uploading into a folder (ie, not the root). When in the root, I'm getting the following error:

Found 1 error while validating the input provided for the PutObject operation: [Key] expected string length to be >= 1, but found string length of 0

Let me know if there's anything else I can provide that would be helpful. 馃憤

bug

Most helpful comment

Nice sleuthing! 馃攳

All 2 comments

I spent some time debugging:

  • Issue only comes up when upload a file directly to the asset container root
  • Problem exists in creating a directory: If no (sub) directory is specified, it tries to create it at / which obviously is not correct.

Findings

Possible solution

Maybe something like

if(pathinfo($path)['dirname'] !== '.') {
    $this->makeDirectory(pathinfo($path)['dirname']);
}

would prevent the creation of the directory. Then the file upload afterwards runs fine.

This is tested with and without subfolder - works so far.

@jasonvarga What do you think?

Nice sleuthing! 馃攳

Was this page helpful?
0 / 5 - 0 ratings