How to recursively upload a directory which has directories and files to a server through HTTPS using curl command?










0














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









share|improve this question









New contributor




Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    0














    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









    share|improve this question









    New contributor




    Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0


      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









      share|improve this question









      New contributor




      Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      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






      command-line bash https curl post






      share|improve this question









      New contributor




      Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 12 hours ago









      DavidPostill

      103k25222256




      103k25222256






      New contributor




      Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 12 hours ago









      Viraj Rathod

      1




      1




      New contributor




      Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Viraj Rathod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          0














          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





          share|improve this answer




















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "3"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            Viraj Rathod is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1387579%2fhow-to-recursively-upload-a-directory-which-has-directories-and-files-to-a-serve%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            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





            share|improve this answer

























              0














              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





              share|improve this answer























                0












                0








                0






                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





                share|improve this answer












                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






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 5 hours ago









                Xen2050

                9,95431536




                9,95431536




















                    Viraj Rathod is a new contributor. Be nice, and check out our Code of Conduct.









                    draft saved

                    draft discarded


















                    Viraj Rathod is a new contributor. Be nice, and check out our Code of Conduct.












                    Viraj Rathod is a new contributor. Be nice, and check out our Code of Conduct.











                    Viraj Rathod is a new contributor. Be nice, and check out our Code of Conduct.














                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1387579%2fhow-to-recursively-upload-a-directory-which-has-directories-and-files-to-a-serve%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    27

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    Category:Rhetoric