Curl mit mehreren POST-Feldern, gleichzeitig File-Upload [Gelöst]

Warum Debian und/oder eine seiner Spielarten? Was muss ich vorher wissen? Wo geht es nach der Installation weiter?
Antworten
jmar83
Beiträge: 962
Registriert: 20.06.2013 20:20:15
Wohnort: CH
Kontaktdaten:

Curl mit mehreren POST-Feldern, gleichzeitig File-Upload [Gelöst]

Beitrag von jmar83 » 28.10.2020 14:12:51

Hallo zusammen

Bin jetzt schon seit ner Weile am recherchieren und man sieht wieder mal alles mögliche...

Mehrere "-F" im Befehl und dahinter jeweils ein Name/Value-Pair, ein "-F" und dahinter mehrere Name/Value-Pairs etc. pp.

Das geht:

Code: Alles auswählen

curl -X POST -s -F upload=@/tmp/db-backup_x_2020-10-28_14-05-36.sql https://www.domain.com/xDistributor/sync/curl/db_bkp/post_db_bkp.php
Also nur 1 Feld, und das ist eine Datei. (Wird der POST damit zum PUT, dies wegen dem `@`...?)

Das nicht:

Code: Alles auswählen

curl -X POST -s -F upload=@/tmp/db-backup_x_2020-10-28_14-05-36.sql sysmail=mail@domain.com https://www.domain.com/xDistributor/sync/curl/db_bkp/post_db_bkp.php
Also mit einem zusätzlichen Feld "sysmail", falls der Server an eine benutzerdefinierte Mailadresse senden soll.

Wie kriege ich gleichzeitig einen File-Upload / Request hin der auch noch eines oder mehere Name/Value-Pairs submitten kann?


Vielen Dank für die Feedbacks! :-)
Zuletzt geändert von jmar83 am 28.10.2020 23:23:34, insgesamt 1-mal geändert.
Freundliche Grüsse, Jan

jmar83
Beiträge: 962
Registriert: 20.06.2013 20:20:15
Wohnort: CH
Kontaktdaten:

Re: Curl mit mehreren POST-Feldern, gleichzeitig File-Upload

Beitrag von jmar83 » 28.10.2020 14:13:45

Und "-F" heisst gemäss meinem aktuellen Wissensstand nicht "File", sondern "Field"...? Also ist es schon das @, was einen File-Upload in die Wege leitet...?
Freundliche Grüsse, Jan

DeletedUserReAsG

Re: Curl mit mehreren POST-Feldern, gleichzeitig File-Upload

Beitrag von DeletedUserReAsG » 28.10.2020 19:19:14

jmar83 hat geschrieben: ↑ zum Beitrag ↑
28.10.2020 14:13:45
Und "-F" heisst gemäss meinem aktuellen Wissensstand nicht "File", sondern "Field"...? Also ist es schon das @, was einen File-Upload in die Wege leitet...?
man curl hat geschrieben: -F, --form <name=content>
(HTTP SMTP IMAP) For HTTP protocol family, this lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to
POST data using the Content-Type multipart/form-data according to RFC 2388.

For SMTP and IMAP protocols, this is the mean to compose a multipart mail message to transmit.

This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an @ sign. To just get the content
part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a
file upload, while the < makes a text field and just get the contents for that text field from a file.

Tell curl to read content from stdin instead of a file by using - as filename. This goes for both @ and < constructs. When stdin is used, the contents
is buffered in memory first by curl to determine its size and allow a possible resend. Defining a part's data from a named non-regular file (such as
a named pipe or similar) is unfortunately not subject to buffering and will be effectively read at transmission time; since the full size is unknown
before the transfer starts, such data is sent as chunks by HTTP and rejected by IMAP.
Die Manpage sollte bei solchen Fragen durchaus am Anfang der Recherche konsultiert werden, das spart u.U. viel Zeit.


OT: „heißt“, „gemäß“

jmar83
Beiträge: 962
Registriert: 20.06.2013 20:20:15
Wohnort: CH
Kontaktdaten:

Re: Curl mit mehreren POST-Feldern, gleichzeitig File-Upload

Beitrag von jmar83 » 28.10.2020 23:23:10

Oh ja vergesse das immer wieder, beginne da immer wie wild zu googeln. So entspricht die Anleitung auch der verwendeten Distri. Vielen Dank!! :THX:
Freundliche Grüsse, Jan

Antworten