gearbox-solutions / eloquent-filemaker

A Model extension and Eloquent driver for Laravel connecting to FileMaker through the Data API
https://gearboxgo.com
MIT License
56 stars 16 forks source link

Can't use a custom filename when uploading to a container #70

Closed alexandrosraikos closed 3 months ago

alexandrosraikos commented 4 months ago

Dependencies

Description of the issue:

Uploaded form files (UploadedFile instances) don't get saved to containers with the desired filename in the container fields. They are being saved with the temporary PHP blob upload name (phpXXXXX without extension).

Expected Behavior:

The file should be uploaded with the desired filename added in the array.

Steps to reproduce:

  1. Retrieve a model instance with a container field.
  2. Set an array [UploadedFile,"filename.ext"] on the attribute which reflects the container attribute.
  3. Save the model SomeModel->save()
  4. The saved file contains the temporary extension less PHP filename instead of the desired name.

Additional Information

After a quick debugging session, I noticed that the query internally in GearboxSolutions\EloquentFileMaker\Services\FileMakerConnection::uploadToContainerField always retrieves the UploadedFile object, no matter if I placed it in an array or not.

Smef commented 4 months ago

I just did a test of this and it seems to be working fine. Can you show me the code which is running into this issue? Here's an example from a file upload form submission which works fine in my tests where a custom name is set:

        $file = $request->file('photo');
        $pet = new Pet();
        $pet->photo = [$file, 'my-photo.jpg'];
        $pet->save();
alexandrosraikos commented 3 months ago

You're right, my bad. The container attribute I was settings also appeared in the fillable array, so for some reason I couldn't get it in the array format.