使用curl命令,将备份好的图片全部重新导入到seaweedfs,图片全部以存储在seaweedfs中的fid命令,

fid中间有一个逗号,使用curl命令时报错:

curl: (26) couldn't open file "6"

curl命令:

curl -X PUT -F "fileUpload=@6,f6f7219fc0" "http://192.168.0.168:8180/6,f6f7219fc0"

其中,http://192.168.0.168:8180是seaweedfs启动的volume server.

解决办法:

使用双引号包含文件名,并开启转义;

curl -X PUT -F "fileUpload=@\"6,f6f7219fc0\"" "http://192.168.0.168:8180/6,f6f7219fc0"

 

导入脚本:

#!/bin/bash

if [ $# -ne 1 ];then
echo "[ Error ] Plead pass the image directory !"
exit 1
fi

ls -alt $1 | awk '{print $9}' | while read line
do
  if [[ $line != "." && $line != ".." ]];then
    if [ $( echo $line | grep "," | wc -l) -eq 1 ];then
      file_path="$1/$line"
      curl -X PUT -F "fileUpload=@\"${file_path}\"" "http://192.168.0.168:8180/${line}"
      echo $file_path
      echo "---------------------------------------------------------------"
    fi
  fi
done

 

图片存储路径: /home/weedfs/20171222

调用命令: sh upload.sh /home/weedfs/20171222

 

相关文章:

  • 2022-12-23
  • 2021-08-31
  • 2021-05-07
  • 2021-06-07
  • 2022-01-19
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2021-07-16
  • 2021-11-10
  • 2021-05-29
  • 2021-12-23
  • 2022-01-01
  • 2022-12-23
相关资源
相似解决方案