Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Cloud Storage Plugin: Nesting a document in dynamic subdirectories

default discord avatar
vaunblu2 years ago
4

I am currently using the S3 adapter for handling documents for our clients. We are using a multi tenant structure for our CMS and therefore have many different clients accessing the same documents collection. As far as I have tested, the file is stored in AWS as the filename. I have prepended the client ID to the front of the filename (123...ABC/file_name.png) so that the file is stored in documents > client ID > filename and there are no conflict in our S3 bucket. It also allows the client docs to be segregated. The structure is right in S3 (pic 1) but the server can't locate the file because it says the key in invalid.



The prefix in my config is "documents" to match my collection (pic 2). It seems like payload cannot access a nested directory starting at the prefix directory. If I change the prefix to a specific client ("documents/123...ABC") it works, but I would rather not make separate collections for each clients documents just so that the prefix matches.



Lastly, even the key in AWS matches the URL but I still get an error saying the key is invalid (pic 3, 4, 5).

  • default discord avatar
    jakey___2 years ago

    This might not help, but in my own configuration of a custom prefix I included a

    /

    at the end of the pathname



    so like

    prefix: 'media/',
  • default discord avatar
    vaunblu2 years ago

    I tried that and got the same error

  • default discord avatar
    jessrynkarlast year

    Hey

    @1028003433090924695

    did you find a solution here? do you still need help?

  • default discord avatar
    vaunblulast year

    I haven't found a solution yet as it seems to be an AWS sdk issue. Payload keys don't seem to register with AWS properly when getting the values through the sdk.



    I've just resorted to giving every file a unique name so there are no conflicts. I figured all organization can be handled through payload rather than having a structured bucket

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.