Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filesystem Disks - How to manage public disks? #201

Closed
radmanz opened this issue Oct 24, 2019 · 11 comments
Closed

Filesystem Disks - How to manage public disks? #201

radmanz opened this issue Oct 24, 2019 · 11 comments
Assignees
Labels

Comments

@radmanz
Copy link

radmanz commented Oct 24, 2019

I currently have an issue where im unable to access a tenants files that have been sucessfully uploaded and stored within the ./storage/tenant_id/app/public/ folder.
I can upload files fine, and they reside within the ./storage/tenant_id/app/public/ folder of the project.
My issue is that i cannot access the files from each tenant. I can only access a single tenants files by symlinking the ./storage/tenant_id/app/public/ -> ./public/storage .

Can anyone give me some pointers as to how I am supposed to setup public storage access for each tenant, so as each tenant may continue to use something like the /storage route to access public files.
Is there a way for php artisan storage:link to faciliate the automation to symlink stoarge to publicly accessable folders?

To give further context as to how my filesystem config is setup, please see the following disks array

'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

You support is greafully appreciated 😊

@stancl
Copy link
Member

stancl commented Oct 24, 2019

Hi,

You can't make a symlink, because the storage directory is variable - it depends on the current tenant's id.

Try using Storage::disk('public') to store the files, and tenant_asset('app/public/...') to get a link to the asset.

@radmanz
Copy link
Author

radmanz commented Oct 28, 2019

hi @stancl ,
Thanks for the help!
I was using spatie/laravel-medialibrary in the case above which was the most confusing part. I found that tenant_asset() was able to parse the media object created by laravel-medialibary which has resolved my support ticket above.

@radmanz radmanz closed this as completed Oct 28, 2019
@cameroncollector
Copy link

cameroncollector commented Feb 14, 2020

Hey @radmanz

Would you mind sharing the code of how you were able to render images in blades? I'm having precisely the same issue of being able to easily upload files but unable to get them to display. Also are you retaining the default folder structure of:
Storage-->tenant[insert_id]-->app-->public

Thanks in advance.

@stancl
Copy link
Member

stancl commented Feb 15, 2020

<img src="{{ asset('foo.jpg') }}"> or <img src="{{ asset('public/foo.jpg') }}">

@phuclh
Copy link

phuclh commented May 15, 2020

<img src="{{ asset('foo.jpg') }}"> or <img src="{{ asset('public/foo.jpg') }}">

Using asset requires a full framework boot. If I have 10 images, that will boot the framework 10 times. Is that correct? Is there any way to access the tenant's image via: Storage::disk('public')->url(tenant()->id . '/image.jpg');?

Thank you for your help!

@stancl
Copy link
Member

stancl commented May 16, 2020

Can't find it right now, but there's some issue thread about this (the Storage url approach).

@andreaverrecchia
Copy link

The private images going under the path storage/app or storage/app/tenant/app?

@Bottelet
Copy link

Bottelet commented Jun 6, 2021

@radmanz @stancl. Is there any more information on this?

I'm experiencing the same, but using tenant_asset('app/public/') makes a URL looking like: tenancy/assets/app/public I am also using Spate image library, but have also tried uploading with Storage::disk('public')->put("...) asset does not work either. But I can render images from the storage/app/public

@stancl
Copy link
Member

stancl commented Jun 7, 2021

Try global_asset()

@Bottelet
Copy link

Bottelet commented Jun 7, 2021

@stancl No luck, I can do global_asset('storage/' which gets an image, if I moved it to the non-tenant folder, but I wanna access the images in the tenant storage folder.

@aroon9002ahmed
Copy link

Hello
i have same problem with viewing image
file uploaded on right location
note: "tenantPTab_saad.sqlite" is my tenant id
image

i'm have tried
{{ Storage::url('images/'.$config->value) }}
{{ asset('storage/images/'.$config->value) }}
{{ asset('app/public/images/'.$config->value) }}

all return 403 (Forbidden) error
image

i'm using sqlite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants