V8-archive: TypeError: Cannot read property 'id' of undefined when adding file (Image)

Created on 18 Jul 2019  路  8Comments  路  Source: directus/v8-archive

Bug Report

Steps to Reproduce

  1. git clone https://github.com/directus/api . and setup scheme based on src/scheme.sql
  2. composer install
  3. Copi version of api.php and setup to s3 upload
  4. Set app => env to anything else than production
  5. Create a collection called test
  6. Add a file field with default setup to the test collection
  7. Create new item in the test collection by uploading a new file

Expected Behavior

File is uploaded and a preview is shown.

Actual Behavior

The file are are being uploaded correctly, and can be found under the file directory.
But are not added to the item you are about the create. Get the following error in the console
image

Other Context & Screenshots

Technical Details

  • Device: Desktop
  • OS: MacOS 10.14.5
  • Web Server: Apache 2.4.37
  • PHP Version: 7.2.0
  • Database: MySQL 8.0.12
  • Install Method: cloned master branch
bug

All 8 comments

Hi @jbitsch

You mentioned that you have been cloned the API repo. So I assume that you are using APP and API individually.

If yes then may I know the version of APP? As I just checked it with the latest version of both of them but not able to replicate it.

Can confirm I have this issue too, though it may be unrelated, I'm using the latest suite release. @bjgajjar

Selection_061

@bjgajjar I found The bug/problem 馃槃
In our api.php we are setting the env under app like so
'app' => [ 'env' => ENV, 'timezone' => 'Europe/Copenhagen', ]

But this breaks the file upload. If i change it to

'app' => [
        'env' => 'production',
        'timezone' => 'Europe/Copenhagen',
 ]

Everything else than production as env makes the file upload break.

The above is tested with a clean installation of both the API and th APP from the master branch.

Maybe you are right. That's why I was not able to replicate this issue. As my env was production.

May not be related, but considering I have the same error in console, it may be...

I'm getting a 500 internal server error when the APP tries to 'PATCH' an item after updating the 'files' with newly selected images.

{
   "photos":[
      {
         "directus_files_id":{
            "id":14,
            "storage":"local",
            "filename":"gabriel-ghnassia-518-unsplash.jpg",
            "title":"Gabriel Ghnassia 518 Unsplash",
            "type":"image/jpeg",
            "uploaded_by":{
               "id":1,
               "status":"active",
               "first_name":"John",
               "last_name":"Smith",
               "email":"[email protected]",
               "token":null,
               "timezone":"UTC",
               "locale":"en-US",
               "locale_options":null,
               "avatar":11,
               "company":null,
               "title":null,
               "email_notifications":true,
               "last_access_on":"2019-07-18T12:52:31+00:00",
               "last_page":"/collections",
               "external_id":null
            },
            "uploaded_on":"2019-04-16T14:33:50+00:00",
            "charset":"binary",
            "filesize":3756879,
            "width":5472,
            "height":3648,
            "duration":null,
            "embed":null,
            "folder":null,
            "description":"",
            "location":"",
            "tags":[

            ],
            "checksum":"310cd81c5b53df81c487301ea53e53cf",
            "metadata":null,
            "data":{
               "full_url":"https://redacted.com/uploads/_/originals/gabriel-ghnassia-518-unsplash.jpg",
               "url":"/uploads/_/originals/gabriel-ghnassia-518-unsplash.jpg",
               "thumbnails":[
                  {
                     "url":"https://redacted.com/thumbnail/_/200/200/crop/good/gabriel-ghnassia-518-unsplash.jpg",
                     "relative_url":"/thumbnail/_/200/200/crop/good/gabriel-ghnassia-518-unsplash.jpg",
                     "dimension":"200x200",
                     "width":200,
                     "height":200
                  }
               ],
               "embed":null
            }
         }
      }
   ]
}

Fixed in #1134

Still facing the same errors in v8.4.0. The annoying thing about it is that further JS isn't working anymore, the upload modal is stuck. The env flag is set to 'production' in my config file _.php.
But I discovered a PHP warning in my JSON response of POST request /_/files:
<b>Notice</b>: Trying to get property 'format' of non-object in <b>/www/htdocs/dev/src/core/Directus/Filesystem/Files.php</b> on line <b>337</b><br /> <br /> <b>Notice</b>: Trying to get property 'duration' of non-object in <b>/www/htdocs/dev/src/core/Directus/Filesystem/Files.php</b> on line <b>337</b><br />

One quick update: ffprobe respectively ffmpeg is used to get the duration and format of an audio file. ffmpeg is rarely offered in shared hosting environments.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maettyhawk picture maettyhawk  路  3Comments

HashemKhalifa picture HashemKhalifa  路  3Comments

andgar2010 picture andgar2010  路  3Comments

benhaynes picture benhaynes  路  4Comments

metalmarco picture metalmarco  路  3Comments