1

This is the command I am using:

curl --insecure -i https://XX.XXX.XXX.XX/project/conatinername/foldertobeuploaded/${file}.html -X PUT -H "Content-Type: text/html charset=UTF-8; -H "Content-Length:0" -H "X-Auth-Token: $token" -T /home/folder/${file}.html

I want to upload a whole directory to my Object Service hosted. Also, I want to give a switch case which will help me upload every file according to the content type.

Here is the sh file

for file in /home/folder/*
 if [ ${extension} == "html" ];
  do
        curl --insecure https://10.147.202.80:8081/swift/v1/JFSTechBackup/${file} -X PUT -H "Content-Type: text/html charset=UTF-8; -H "Content-Length:0" -H "X-Auth-Token: $token" -T /home/folder/${file}

 elif [ ${extension} == "css" ]; then
   do
         curl --insecure https:/home/folder/${file} -X PUT -H "Content-Type: text/css -H "X-Auth-Token: $token" -T /home/folder/${file}
 else if [ ${extension} == "png" ]; then
   do
        curl --insecure https:/home/folder/${file} -X PUT -H "Content-Type: image/png -H "X-Auth-Token: $token" -T /home/folder/${file}

fi

1 Answer 1

1

I'm not going to attempt re-writing your script, but to recursively find all files you could use find, for example to find all regular files

find directory -type f

or to find everything that's not a directory

find directory \! -type d

Then you could run some command on each item, xargs would be great (with null-separated names here)

find directory \! -type d -print0 | xargs -0 curl ...

If you wanted the filename extension examining & processing, then you could use a separate find for each -name *.extension type, or use something like a while read loop

find directory \! -type d | while read onthisfile; do echo Processing "$onthisfile; done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .