ibm-cloud-docs / cloud-object-storage

cloud-object-storage
15 stars 46 forks source link

Upload an object not working with -d argument #160

Closed aquddos123 closed 1 year ago

aquddos123 commented 1 year ago

I've tried several options to upload a zip file using -d argument but didn't work. When I replaced it with -T it worked.

curl -X "PUT" "https://(endpoint)/(bucket-name)/(object-key)" \
 -H "Authorization: bearer (token)" \
 -H "Content-Type: (content-type)" \
 -T "(object-contents)"
KyungmoIBM commented 1 year ago

Hello @aquddos123, "-T" tells curl to upload file, and "-d" option tells http post data(content). So

This command will upload test.json to with object key name test.json

curl -X "PUT" "https://(endpoint)/(bucket-name)/test.json" \
 -H "Authorization: bearer (token)" \
 -H "Content-Type: (content-type)" \
 -T "test.json"

However, this command will create test.json object that contains text "test.json"'

curl -X "PUT" "https://(endpoint)/(bucket-name)/test.json" \
 -H "Authorization: bearer (token)" \
 -H "Content-Type: (content-type)" \
 -d "test.json"

Please see this help information;

curl --help
Usage: curl [options...] <url>
 -d, --data <data>          HTTP POST data
 -f, --fail                 Fail fast with no output on HTTP errors
 -h, --help <category>      Get help for commands
 -i, --include              Include protocol response headers in the output
 -o, --output <file>        Write to file instead of stdout
 -O, --remote-name          Write output to a file named as the remote file
 -s, --silent               Silent mode
 -T, --upload-file <file>   Transfer local FILE to destination
 -u, --user <user:password> Server user and password
 -A, --user-agent <name>    Send User-Agent <name> to server
 -v, --verbose              Make the operation more talkative
 -V, --version              Show version number and quit