小编das*_*h00的帖子

如何在linux bash/shell中对base64进行编码

我正在尝试base64编码shell脚本中的图像并将其放入变量:

test="$(printf DSC_0251.JPG | base64)"
echo $test
RFNDXzAyNTEuSlBH
Run Code Online (Sandbox Code Playgroud)

我也尝试过这样的事情:

test=\`echo -ne DSC_0251.JPG | base64\`
Run Code Online (Sandbox Code Playgroud)

但仍然没有成功.

我想做这样的事情:

curl -v -X POST -d '{"image":$IMAGE_BASE64,"location":$LOCATION,"time_created":$TIMECREATED}' -H 'Content-type: text/plain; charset=UTF8' http://192.168.1.1/upload
Run Code Online (Sandbox Code Playgroud)

我发现了这个http://www.zzzxo.com/q/answers-bash-base64-encode-script-not-encoding-right-12290484.html

但仍然没有成功.

linux variables shell base64 image

79
推荐指数
3
解决办法
13万
查看次数

标签 统计

base64 ×1

image ×1

linux ×1

shell ×1

variables ×1