powered by simpleCommunicator - 2.0.49     © 2025 Programmizd 02
Форумы / Программирование [игнор отключен] [закрыт для гостей] / Curl post zip file
8 сообщений из 8, страница 1 из 1
Curl post zip file
    #40061029
roma126
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Привет всем. Требуется отправить на url zip file из абсолютного пути c:/path (Windows). Curl -F file="@c:/path/'zipfile.zip" url
не получается. Заранее спасибо!
...
Рейтинг: 0 / 0
Curl post zip file
    #40061041
Dima T
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
А url это куда? Что там за сервер?
...
Рейтинг: 0 / 0
Curl post zip file
    #40061048
roma126
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
Curl post zip file
    #40061059
Dima T
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
У тебя одинарная кавычка лишняя Curl -F file="@c:/path/ ' zipfile.zip" url
попробуй в двойные кавычки взять всю подстроку
Код: sql
1.
Curl -F "file=@c:/path/zipfile.zip" url


Ну и если это HTTP то наверно надо метод POST использовать
Код: sql
1.
Curl -X POST -F "file=@c:/path/zipfile.zip" url



PS Если ничего не поможет - показывай сюда что Curl пишет, там сообщение об ошибке должно быть.
...
Рейтинг: 0 / 0
Curl post zip file
    #40061063
roma126
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
302 пишет ответ. Судя по всему, action не находит файл и перенаправляет.
...
Рейтинг: 0 / 0
Curl post zip file
    #40061146
Basil A. Sidorov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
вырезка из curl --manual
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
       -T, --upload-file <file>
              This  transfers  the  specified local file to the remote URL. If
              there is no file part in the specified URL, curl will append the
              local file name. NOTE that you must use a trailing / on the last
              directory to really prove to Curl that there is no file name  or
              curl will think that your last directory name is the remote file
              name to use. That will most likely cause the upload operation to
              fail. If this is used on an HTTP(S) server, the PUT command will
              be used.

              Use the file name "-" (a single dash) to use stdin instead of  a
              given  file.   Alternately,  the file name "." (a single period)
              may be specified instead of "-" to  use  stdin  in  non-blocking
              mode  to  allow  reading  server output while stdin is being up-
              loaded.

              You can specify one -T, --upload-file for each URL on  the  com-
              mand  line.  Each -T, --upload-file + URL pair specifies what to
              upload and to where. curl also supports "globbing"  of  the  -T,
              --upload-file  argument,  meaning  that  you can upload multiple
              files to a single URL by using the same URL globbing style  sup-
              ported in the URL, like this:

               curl --upload-file "{file1,file2}"  http://www.example.com 

              or even

               curl -T "img[1-1000].png" ftp://ftp.example.com/upload/

              When  uploading  to an SMTP server: the uploaded data is assumed
              to be RFC 5322 formatted. It has to feature the necessary set of
              headers  and  mail  body formatted correctly by the user as curl
              will not transcode nor encode it further in any way.
...
Рейтинг: 0 / 0
Curl post zip file
    #40061742
roma126
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Basil A. Sidorov,

Так не идет. Дело в том, что файл zip нужно передать как параметр формы -F file=..., а дальше вот вопрос как уложить его. В параметрах передачи post он выглядит как набор символов, разделенный по boundary коду.
...
Рейтинг: 0 / 0
Curl post zip file
    #40061803
Basil A. Sidorov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
ещё одна, мопвашуять, вырезка
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
       -d, --data <data>
              (HTTP MQTT) Sends the specified data in a POST  request  to  the
              HTTP server, in the same way that a browser does when a user has
              filled in an HTML form and presses the submit button. This  will
              cause curl to pass the data to the server using the content-type
              application/x-www-form-urlencoded.  Compare to -F, --form.

              --data-raw is almost the same but does not have a special inter-
              pretation  of  the  @ character. To post data purely binary, you
              should instead use the --data-binary option.  To URL-encode  the
              value of a form field you may use --data-urlencode.

              If  any of these options is used more than once on the same com-
              mand line, the data pieces specified  will  be  merged  together
              with  a  separating  &-symbol.  Thus,  using  '-d name=daniel -d
              skill=lousy'  would  generate  a  post  chunk  that  looks  like
              'name=daniel&skill=lousy'.

              If  you  start  the data with the letter @, the rest should be a
              file name to read the data from, or - if you want curl  to  read
              the  data  from  stdin.  Posting data from a file named 'foobar'
              would thus be done with -d, --data @foobar. When -d,  --data  is
              told  to  read  from a file like that, carriage returns and new-
              lines will be stripped out. If you don't want the @ character to
              have a special interpretation use --data-raw instead.

              See  also  --data-binary,  --data-urlencode and --data-raw. This
              option overrides -F, --form and -I,  --head  and  -T,  --upload-
              file.
И этот вариант уже упоминал Dima T.
Читайте, в общем, доки.
...
Рейтинг: 0 / 0
8 сообщений из 8, страница 1 из 1
Форумы / Программирование [игнор отключен] [закрыт для гостей] / Curl post zip file
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]