novanda1/payload-imagekit

AITags can't be saved

Closed this issue · 1 comments

zanami commented

I'm trying to use AITags in savedProperties
I'm using version 0.2.4 but field handling seems unchanged in 0.2.5 (all fields are text unless it's width, height and some boolean)

ERROR (payload): ValidationError: media validation failed: imagekit.AITags: Cast to string failed for value "[
  { name: 'Sky', confidence: 97.46, source: 'google-auto-tagging' },
  { name: 'Train', confidence: 96.37, source: 'google-auto-tagging' },
  { name: 'Cloud', confidence: 95.96, source: 'google-auto-tagging' }
]" (type Array) at path "AITags"

Yep that because we can't save stringified array into MongoDB text.
So instead of save all object we can just save the tags into inline string separated by comma like this:

Nature,Night,Outdoors,Scenery,Sky,Atmosphere,Cloud,World,Mountain,Snow,Natural landscape,Biome,Atmospheric phenomenon,Tree

If you need use that in array, you can split that. tags.split(",")