lara-zeus / bolt

form builder for your users, with so many use cases
https://larazeus.com/bolt
MIT License
172 stars 31 forks source link

[Bug]: Files in 'file upload' field does not work #278

Closed Pedynho closed 4 months ago

Pedynho commented 4 months ago

What happened?

When the 'file upload' input was used in any form, the file was not uploaded to the 's3' driver, for example. When we checked the response, the file was not available.

How to reproduce the bug

use the file upload field ina form and try to upload and try to see the file attached.

Package Version

^3

PHP Version

8.2.7

Laravel Version

^10.10

Which operating systems does with happen with?

Linux

Notes

No response

atmonshi commented 4 months ago

did you set the uploadDisk in the configuration file?

to publish the config

Pedynho commented 4 months ago

Yes I didi it. It sounds like a permission error. For example, using the native Filament 3 upload input, I can pass the option ->visibility('private'). Without that option, the file features don't work. When I use the file upload feature of Bolt, there is an error accessing the object, and the file does not exist in the bucket, showing that the upload did not work

atmonshi commented 4 months ago

ok I will add the missing configuration for the file upload soon

On Mon, Apr 29, 2024 at 3:18 PM Pedro Gomes @.***> wrote:

Yes I didi it. It sounds like a permission error. For example, using the native Filament 3 upload input, I can pass the option ->visibility('private'). Without that option, the file features don't work. When I use the file upload feature of Bolt, there is an error accessing the object, and the file does not exist in the bucket, showing that the upload did not work

— Reply to this email directly, view it on GitHub https://github.com/lara-zeus/bolt/issues/278#issuecomment-2082457858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO4VHC62XFMOYMAX7KF3TDY7YUB7AVCNFSM6AAAAABG2W3WYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBSGQ2TOOBVHA . You are receiving this because you commented.Message ID: @.***>

atmonshi commented 4 months ago

can you test #280 and let me know.

change the composer to "lara-zeus/bolt": "dev-upload-visibility",

and add 'uploadVisibility' => 'public', to your config

Pedynho commented 4 months ago

I've encountered a few issues with my app after update the package, but the most important one is related to file uploads to Amazon S3. When I set the visibility to 'public', the file doesn't upload to S3 at all. However, when I switch it to 'private', the file successfully uploads, but the URL generated to view the file in the app differs from the expected public URL format.

The URL in the app appears as: https://s3.amazonaws.com/$bucket/$folder/$filename.jpg

I suspect the URL is missing a necessary signature or thing like taht on url query params for the user to be able to view the file.

Additionally, I am using the 'livewire:bolt.fill-form' tag component to display the form on my customized page.

atmonshi commented 4 months ago

I dont use S3 so I really cant test it. other than the disk , directory and visibility

what other configuration you'll need for file upload with s3?

all changes in this file: https://github.com/lara-zeus/bolt/pull/280/files#diff-6031be39b8f7227ff4654867bd180d179da8a6a4d5da4f81d94a5fff7d695c33

atmonshi commented 4 months ago

also I am using

Storage::disk(config('zeus-bolt.uploadDisk'))->url($file)

to get the file url, check the file: resources/views/filament/fields/file-upload.blade.php

if you can debug around and let me know what I am missing!

thank you.

Pedynho commented 4 months ago

Good news... the 'UploadVisibility' solved the problem of uploading to S3.

To solve the visualization issue, I changed the published file 'file-upload.blade.php' as follows:

path to file: src/resources/views/vendor/zeus/filament/fields/file-upload.blade.php


<div class="p-1 my-2 gap-2 flex">
    @foreach($responseValue as $file)
        <x-filament::button
            tag="a" target="_blank" size="sm" outlined
            href="{{ Storage::disk(config('zeus-bolt.uploadDisk'))->temporaryUrl($file, now()->addMinute()) }}">
            {{ __('view file') .': '. $loop->iteration }}
        </x-filament::button>
    @endforeach
</div>
atmonshi commented 4 months ago

great, so the change in the view can be done on the app url, since its diss from app to another.

I'll merge the PR. thank you.