S3 custom path relative to bucket while uploading during entry creation

I’ve tried just about everything I could think of here. Any pointers on how to format my request to supply a custom path for an S3 file upload during entry creation? The docs do not give an example for adding any additional parameters during entry creation.

            // Current code looks something like this and works fine for the entry + file
            formData.append('data', JSON.stringify(data))

            formData.append(`files.media`,
                this.input.files[name].fileObject,
                this.getFilename(name))

          // I've tried a few things like the following, none seem to work:
          formData.append(`files.media.path`, `uploads`)
          formData.append(`files.path`, `uploads`)
          formData.append(`path`, `uploads`)

Thanks,
reppard

Can someone let me know if this is even possible?

That should be the correct option per: https://strapi.io/documentation/v3.x/plugins/upload.html#upload-files-related-to-an-entry

  • path (optional): The folder where the file(s) will be uploaded to (only supported on strapi-provider-upload-aws-s3).

What Strapi version are you currently using so that I can try to spin up a test?

Hey DMehaffy, thanks for the response. Here are my strapi deps from my package.json:
“strapi”: “3.1.4”,
“strapi-admin”: “3.1.3”,
“strapi-connector-bookshelf”: “3.1.3”,
“strapi-plugin-content-manager”: “3.1.3”,
“strapi-plugin-content-type-builder”: “3.1.3”,
“strapi-plugin-email”: “3.1.3”,
“strapi-plugin-upload”: “3.1.3”,
“strapi-plugin-users-permissions”: “3.1.3”,
“strapi-provider-upload-aws-s3”: “^3.1.5”,
“strapi-utils”: “3.1.3”,
“strip-ansi”: “^6.0.0”

I assumed “Upload file during entry creation” would be similar to “Upload files related to an entry” though that didn’t prove to be the case for me. I did try to look into the upload plugin code and the s3 provider but nothing obvious jumped out at me.

Did you have any luck on this? Is there any other info I could provide that might be helpful?

I was also digging in trying to find out how to add altText and captions for uploads during entity creation.

There is no fileInfo or metas being passed to enhancedFile in this uploadToEntity call. Is it possible that this is why path isn’t working as I was expecting?

You will have some issues here, you are mixing a few different versions of our packages. They should all be the same without the little ^ before them.

noted, i was experimenting with different versions and hadn’t come back to clean this up. thanks

Do let me know if the version cleanup fixed the issue :slight_smile:

Just circling back around to this thread to drop some context for anyone else who might stumble on this. Dependencies didn’t seem to be the issue. After further digging into strapi I ended up opening an issue here Upload during entity creation does not support path, alternativeText, caption, etc. · Issue #8467 · strapi/strapi · GitHub

Thank you @reppard I’ve set it into our eng-teams bug report backlog so they can take a look.