Class: Capsolver::FileInstrument
- Inherits:
-
Object
- Object
- Capsolver::FileInstrument
- Defined in:
- lib/capsolver/file_instrument.rb
Instance Method Summary collapse
-
#file_processing(captcha_link: nil, captcha_file: nil, captcha_base64: nil, save_format: "temp", img_clearing: true, file_path: "/tmp/", file_extension: "png", **kwargs) ⇒ Object
(also: #aio_file_processing)
Synchronously processes the file/link/base64 to a base64 encoded string.
Instance Method Details
#file_processing(captcha_link: nil, captcha_file: nil, captcha_base64: nil, save_format: "temp", img_clearing: true, file_path: "/tmp/", file_extension: "png", **kwargs) ⇒ Object Also known as: aio_file_processing
Synchronously processes the file/link/base64 to a base64 encoded string.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/capsolver/file_instrument.rb', line 11 def file_processing( captcha_link: nil, captcha_file: nil, captcha_base64: nil, save_format: "temp", img_clearing: true, file_path: "/tmp/", file_extension: "png", **kwargs ) if captcha_file content = File.binread(captcha_file) Base64.strict_encode64(content) elsif captcha_base64 Base64.strict_encode64(captcha_base64) elsif captcha_link content = url_read(captcha_link, **kwargs) if save_format == "const" full_path = file_const_saver(content, file_path, file_extension) file_clean(full_path) if img_clearing end Base64.strict_encode64(content) else raise ArgumentError, "No valid captcha variant is set." end end |