Open humbroll opened 10 years ago
User data like below.
"user"=>{"profile_image"=>#<ActionDispatch::Http::UploadedFile:0x007fe8ad6eaeb8 @tempfile=#<Tempfile:/var/folders/mv/9n4zpk597fgc4hgm69v2dljm0000gn/T/RackMultipart20131224-3012-oayy5p>, @original_filename="blogfiles.naver-1.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[profile_image]\"; filename=\"blogfiles.naver-1.jpeg\"\r\nContent-Type: image/jpeg\r\n">, "email"=>"qwerasdf@sk.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}
Own validator is probably the way to go
@humbroll did you manage to create a file validator?
@chrise86
class FileValidator < Apipie::Validator::BaseValidator
def validate(value)
value.is_a?(Rack::Test::UploadedFile) || value.is_a?(ActionDispatch::Http::UploadedFile)
end
def self.build(param_description, argument, options, block)
self.new param_description if argument == File
end
def description
'Must be a valid file'
end
end
@muichkine awesome thanks!
thanks
@muichkine Very helpful, thanks much.
How generate documentation with this validatior.
:show_in_doc gets error
How we can handle base64 image format?
param :file, ActionDispatch::Http::UploadedFile, ... work for me
@oliviermilla How do I use the custom defined validator?
Do I just do this?:
param :name, CustomValidator, (...)
@oliviermilla How do I use the custom defined validator?
Do I just do this?:
param :name, CustomValidator, (...)
I don't remember, it was 8 years ago. :)
I just wonder what kind of param type of attachment(image). Should I define own validator?