The -F
option tells curl to POST
the provided data using the HTTP "multipart/form-data"
Content-Type, which looks like this at the HTTP layer:
POST /api/v4/track/upload HTTP/1.1
Host: developer.echonest.com
Content-Type: multipart/form-data; boundary="boundaryvalue"
--boundaryvalue
Content-Disposition: form-data; name="api_key"
FILDTEOIK2HBORODV
--boundaryvalue
Content-Disposition: form-data; name="filetype"
mp3
--boundaryvalue
Content-Disposition: form-data; name="track"; filename="audio.mp3"
Content-Type: audio/x-mpg
<binary audio data here>
--boundaryvalue--
The Post()
method of Indy's TIdHTTP
component implements that Content-Type via the TIdMultipartFormDataStream
utility class, eg:
uses
..., IdHTTP, IdMultipartFormData;
var
Data: TIdMultipartFormDataStream;
begin
Data := TIdMultipartFormDataStream.Create;
try
Data.AddFormField('api_key', 'FILDTEOIK2HBORODV');
Data.AddFormField('filetype', 'mp3');
Data.AddFile('track', 'C:\path to\audio.mp3');
IdHTTP1.Post('http://developer.echonest.com/api/v4/track/upload', Data);
finally
Data.Free;
end;
end;