joas8211 / payload-tenancy

Multi-tenancy plugin for Payload CMS
MIT License
122 stars 6 forks source link

Cloud Media Uploads broken with tenancy #20

Closed MarkKropf closed 10 months ago

MarkKropf commented 10 months ago

Hello,

Thank you for building this ๐Ÿ‘

I'm using the Cloud Upload plugin to keep my media in a storage bucket. I'm able to upload while logged into a tenant (tested both path & user strats) and the file gets uploaded. I'm not however able to GET the image via any combination of paths to the asset. While uploading, I get the following error:

[18:14:30] ERROR (payload): TypeError: Cannot read properties of undefined (reading 'skipTenancyUploadAfterReadHook')
    at /Volumes/GenericUser/GenericUser/payload-cms/node_modules/payload-tenancy/dist/hooks/upload.js:67:41
    at step (/Volumes/GenericUser/GenericUser/payload-cms/node_modules/payload-tenancy/dist/hooks/upload.js:44:23)
    at Object.next (/Volumes/GenericUser/GenericUser/payload-cms/node_modules/payload-tenancy/dist/hooks/upload.js:25:53)
    at /Volumes/GenericUser/GenericUser/payload-cms/node_modules/payload-tenancy/dist/hooks/upload.js:19:71
    at new Promise (<anonymous>)
    at __awaiter (/Volumes/GenericUser/GenericUser/payload-cms/node_modules/payload-tenancy/dist/hooks/upload.js:15:12)
    at /Volumes/GenericUser/GenericUser/payload-cms/node_modules/payload-tenancy/dist/hooks/upload.js:61:16
    at /Volumes/GenericUser/GenericUser/payload-cms/node_modules/payload/src/collections/operations/find.ts:223:24
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Volumes/GenericUser/GenericUser/payload-cms/node_modules/payload/src/collections/operations/find.ts:220:7

The media upload gets mapped to a correct looking URL: User Strategy

http://localhost:3000/media/images/random-image.jpg

Path Strategy

http://localhost:3000/root/media/images/random-image.jpg

But both result in a failure to retrieve the media asset:

Cannot GET /media/images/random-image.jpg
joas8211 commented 10 months ago

I created an update (v1.1.3). Can you confirm if there still is a problem?

MarkKropf commented 10 months ago

Thank you ๐Ÿ™