3

I'm using Directus for a headless CMS. I have been uploading a file through the Directus App but the API returns null for the file field.

How can I fix this issue?

GreensterRox
  • 6,432
  • 2
  • 27
  • 30
yuku
  • 33
  • 6

3 Answers3

3

(I can't comment due to reputation)

Are you ensuring this is an authenticated call, if you would like to make this a public call so anyone can access it (IE: A website frontend), then you might want to allow public READ access to directus_files.

Shea Lavington
  • 436
  • 2
  • 7
  • I enabled it in Setting > Role and Permission > Public > System collection and then allowed read of files – yuku Jun 19 '19 at 13:36
  • this is public api – yuku Jun 19 '19 at 13:37
  • 2
    Has the file actually been saved in the entry you're requesting? I know there's an existing bug where files aren't being saved properly to a field. Are you requesting the `files` endpoint, or your own collection with a related file? – Shea Lavington Jun 19 '19 at 13:41
  • I access it within [project]/_/files?access_token=[token], I guess did not attach file to item ?! – yuku Jun 19 '19 at 13:54
  • I requesting collection only without any parameter – yuku Jun 19 '19 at 14:00
3

If you are running the latest version of Directus, apparently there is a bug that completely blows up the File field. The files get uploaded but it doesn't get linked to the field.

https://github.com/directus/api/issues/1015

It should be fixed in the next build.

Lazar
  • 148
  • 6
  • what can i do now ? just waiting ?! :) – yuku Jun 22 '19 at 05:53
  • 1
    New version just came out https://github.com/directus/directus/releases/tag/190621A I just upgraded and it seems to work now. Upgrade instructions here: https://docs.directus.io/guides/upgrading.html – Lazar Jun 22 '19 at 06:22
2

Use the fields parameter to get nested relational files. If the API is public and the file returns null, please verify that the public role has read access to the directus_files collection.

Rijk
  • 939
  • 7
  • 17