Cant upload images with an api request

Issue #35 closed
Former user created an issue

Hi, i cant upload images/fal with an api call. I make everything like in the docs described but nothing worked. Without images the call works perfectly. I got the follow error if i try to upload an image.

BTW: is it possible that you share an working example extension with an image/fal upload?

Comments (8)

  1. David Bascom

    Thanks for reporting. Probably has to do with your database settings. It tries to write an empty string in a field that should be an int (which I will correct in the next update). Depending on the database-settings, this will not throw an error and automatically convert it to a “0”. (https://stackoverflow.com/questions/28606483/how-to-allow-empty-string-for-integer-in-mysql)

    Lots of updates coming in a few days. Have a look at the commits for nnrestapi and nnhelpers :)
    Quick fix could be:

    Look for the method fromFile in Nng\Nnhelpers\Utilities\Fal. You will see an $entry array.
    Add this line to the array and see if it works:
    'uid_foreign' => 0,

    One more thing which is not documented correctly in the current version: You MUST have the @Api\Upload("...")Annotation set – otherwise the files will not get moved from the /tmp folder to your destination folder:

    https://docs.typo3.org/p/nng/nnrestapi/main/en-us/Annotations/Annotations/60_Upload.html

  2. GNBhava

    Your solution 'uid_foreign' => 0, Not working either, It shows “Field 'files' doesn't have a default value” even after selecting file.

    Also, if you put configuration into LocalConfiguration.php it does not throw error. But, database entry will be null

    'initCommands' => 'SET SESSION sql_mode=\\'\\'',
    

  3. GNBhava

    Hi David,

    I have composer setup with ddev and versions are below:

    • TYPO3 12 LTS
    • EXT:headless 4.1.1
    • EXT:nnrestapi 2.0.3

    Thank you!

  4. Stig Nørgaard Færch

    @GNBhava
    You forgot to mention PHP-version and database information (Maria, MySQL - version?).

  5. Log in to comment