对于google-api-client gem版本0.19.4我尝试使用Google :: Apis :: AdminDirectoryV1获取所有用户及其照片。
当我使用photo_data字段获取用户照片(Google :: Apis :: AdminDirectoryV1 :: UserPhoto)时,我会得到一个十六进制字符串。我无法将其转换为图像?
如何将数据转换为图像。无法在任何地方找到解决方案。
如the documentation所述,该字段是base64编码的。
使用base64,例如:
require "base64"
enc = Base64.encode64('Send reinforcements')
# -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
plain = Base64.decode64(enc)
# -> "Send reinforcements"