How to recursively upload a directory which has directories and files to a server through HTTPS using curl command?
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
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.
add a comment |
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
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.
add a comment |
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
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
command-line bash https curl post
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.
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
answered 5 hours ago
Xen2050
9,95431536
9,95431536
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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