Warning: Couldn't read data from file - http-put

When i try to do an HTTP PUT request to upload a data file .img on image OpenStack like this:
curl -i -X PUT -H "X-Auth-Token: $Token" -H "Content-Type: application/octet-stream" -d "#/home/nic/cirros-0.3.5-x86_64-disk.img" 192.168.1.107:9292/v2/images/$ID_IMAGE/file
i receive this message:
Warning: Couldn't read data from file
Warning: "/home/nic/cirros-0.3.5-x86_64-disk.img", this makes an empty POST.
HTTP/1.1 204 No Content
I try to use absolute and relative path but it doesn't work.

Related

How can i send a base64 image to Azure Face-API with curl?

as my question mention it, how do i need to change this statement to send an image in base64 to Azure?
curl -H "Ocp-Apim-Subscription-Key: ***hidden***" "https://***hidden***.cognitiveservices.azure.com/face/v1.0/detect?detectionModel=detection_03&returnFaceId=true&returnFaceLandmarks=false"
-H "Content-Type: application/json" --data-ascii "{\"url\":\"https://upload.wikimedia.org/wikipedia/commons/c/c3/RH_Louise_Lillian_Gish.jpg\"}"
Thank you!
how do i need to change this statement to send an image in base64 to Azure?
As per this documentation, your curl command seems fine.
Alternatively, you can try as suggested by muru:
'{"image" : "'"$( base64 ~/Pictures/1.jpg)"'"}
Updated answer:
As per Use the Face client library:
curl -v -X POST "https://westus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes={string}&recognitionModel=recognition_04&returnRecognitionModel=false&detectionModel=detection_03&faceIdTimeToLive=86400" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: {subscription key}" --data-ascii "{\"url\":\"https://csdx.blob.core.windows.net/resources/Face/Images/identification1.jpg\"}"
You can refer to similar issues: can't send/request base64 to azure face api with python and Face API need support for base64 string or Local File URL or Native File URL instead of Image URL
curl -X POST "https://.cognitiveservices.azure.com/face/v1.0/detect" -H "Content-Type: application/octet-stream" -H "Ocp-Apim-Subscription-Key: 27e993*********6aaa2464" --data-binary #'/home/rafael/Downloads/person.jpg'
is the solution that works. As far as I can tell, the documentation seems outdated.

Want to call batch file with node script, get garbled time

I want to create a cron job with a batch file which is using curl to login into a page saving the login token and then run a node script to do something. But when I call my batch file I get
batch: garbled time
My script:
#!/bin/bash
# A simple script to automate something
curl 'someurl' -H 'content-type: application/json' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: someurl' --data-binary '{"some login data"}' -i -O
node doSomething.js
If you are trying to submit your script as a crontab file, then it's in the wrong format. You need to specify time-related fields at the start of the line. See https://en.wikipedia.org/wiki/Cron
The error message you got is typical of a bad time specification.

Using CURL to upload to Dropbox and overwrite a file

I'm a small time admin and would say entry level to Linux. I am trying to use CURL to upload to Dropbox a small backup sqlitedb and have had success for the first upload, however, I am trying to accomplish uploading a file to Dropbox every 30 minutes and overwriting the current file in DROPBOX with the new file from my Linux server (as a jerry-rigged offsite backup of my Teamspeak database)
This is the code I have so far :
curl -X PUT https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer <dropbox code here>" \
--header "Dropbox-API-Arg: {\"path\": \"/home/ec2-user/ts3server.sqlitedb.bz2\"}" \
--header "Content-Type: application/octet-stream" \
--data-binary ts3server.sqlitedb.bz2
After running that code once, it doesn't OVERRIDE the current file in my Dropbox account with the updated file. Any help is appreciated
you need to use mode with parameter overwrite. The default is add.
Add - Do not overwrite an existing file if there is a conflict. The autorename strategy is to append a number to the file name. For
example, "document.txt" might become "document (2).txt".
overwrite - Always overwrite the existing file. The autorename strategy is the same as it is for add.
Reference: /upload
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer " \
--header "Dropbox-API-Arg: {\"path\": \"/Homework/math/Matrices.txt\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary #local_file.txt

cURL not sending file data

I have a cURL call that I'm trying to use to send file data to a remote server.
curl -X POST -u username:password -d 'data=#/path/to/file.ext&version=2&action=Parse' http://fqdn.to.server.i.control/Parser.cgi
curl -X POST -u username:password -d 'data=#localFile.ext&version=2&action=Parse' http://fqdn.to.server.i.control/Parser.cgi
cat file.ext | curl -X POST -u username:password -d 'data=#-&version=2&action=Parse' http://fqdn.to.server.i.control/Parser.cgi
The file contents are URI encoded already. Using Perl and CGI on the server side.
My problem is that when the server tries to access that "data" line, value I have is only "file.ext" - the path is stripped out and the file's contents are not used ($cgi->param("data") is just "file.ext", "localFile.ext" or "-" respectively).
Any indication as to what I'm doing wrong?
#MattJacob was correct; my syntax was wrong. data=#... should have been #... and the data= portion should have been in the file. Boy am I thick.

curl command in linux

How we can add JSON parameters in a curl command to fetch data ?
PS: I have tried to fetch data from some source using curl command but it requires passing JSON parameters in it. So how I will accomplish it ?
I think mentioning content type as json and passing data will do the things right
curl -H "Content-Type: application/json" -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here
Above will work for GET Method, for POST method
curl -H "Content-Type: application/json" -X POST -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here

Resources