form_forto be able to upload a file and now I am getting
web | POST /images web | ▸ Handled by Images::Create web | ▸ Lucky::MissingNestedParamError web | web | Missing param key: 'image' web | web | Backtrace web | web | lib/lucky/src/lucky/params.cr:168:7 in 'nested' web | src/models/image.cr:12:3 in 'permitted_params'
assetand it is send in multipart, not in form data. Operation looks only yo form data, and if it cannot find required param key, exception is raised. I fixed the problem aboce by adding another field to the form – a text field.
What type should I specify for uploaded files in Operations? Using
class SaveImage < Image::SaveOperation param_key :image attribute asset : Lucky::UploadedFile attribute title : String before_save :assign_asset def assign_asset pp! asset.inspect end end
Lucky::UploadedFileraises an error
web | In src/operations/save_image.cr:9:21 web | web | 9 | attribute asset : Lucky::UploadedFile web | ^ web | Error: undefined constant Lucky::UploadedFile::Lucky
Lucky::UploadedFilewill probably need something similar.
JSON::Any. Let us know if you run into anything with that. I'll try to help the best I can :D
Good artists copy; great artists steal.