Ruby ruby 16 进制如何装换成文件 (图片)

fwl123456 · September 09, 2019 · Last by fwl123456 replied at September 09, 2019 · 4671 hits

如图所示,接口返回显示图片,代码测试返回一串 16 进制字符串,我如何才能把这个 16 进制字符串装换为图片保存到数据库呢?

image_data = response.body.force_encoding(Encoding::UTF_8)

File.open("#{Dir.pwd}/public/captcha.png", 'w') { |file| file.write(image_data) }

You need to Sign in before reply, if you don't have an account, please Sign up first.