#http #curl #upload
Вопрос:
У меня есть файл .tgz локально, который я могу загрузить на сервер с помощью groovy с помощью:
File file = container.file("/home/user/temp/data-1-0.11.tgz")
def response = HttpBuilder.configure {
request.uri = 'https://internal.storage/data-1-0.11.tgz'
request.contentType = 'text/plain'
request.charset = Charsets.UTF_8
}.post {
request.body = Base64.getEncoder().encodeToString(file.bytes)
}
Я хотел бы сделать то же самое, используя обычный завиток. Основанный на:
https://superuser.com/questions/1054742/how-to-post-file-contents-using-curl/1054792
Я пробовал ( тонны других комбинаций):
curl -d "data=@/home/user/temp/data-1-0.11.tgz" https://internal.storage/data-1-0.11.tgz
curl -d "data=@path/home/user/temp/data-1-0.11.tgz" https://internal.storage/data-1-0.11.tgz
Но это дает:
{"timestamp":1623789703486,"status":415,"error":"Unsupported Media Type","message":"Content type 'application/x-www-form-urlencoded' not supported","path":"/data-1-0.11.tgz"}
Нужно ли мне конвертировать файл tgz в строку, прежде чем я смогу загрузить его с помощью curl?