Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with IdHTTP do
- begin
- HTTPOptions := [hoForceEncodeParams];
- AllowCookies := True;
- HandleRedirects := True;
- ProtocolVersion := pv1_1;
- end; // with
- Stream := TIdMultipartFormDataStream.Create;
- EncodedFileName := TIdEncoderMIME.EncodeString(ExtractFileName(Trim(FileName)), IndyUTF8Encoding);
- EncodedFileName := StringReplace(EncodedFileName, '+', '-', [rfReplaceAll, rfIgnoreCase]);
- EncodedFileName := StringReplace(EncodedFileName, '/', '_', [rfReplaceAll, rfIgnoreCase]);
- EncodedFileName := StringReplace(EncodedFileName, '=', ',', [rfReplaceAll, rfIgnoreCase]);
- with Stream.AddFormField('file_name', EncodedFileName, 'utf-8') do
- begin
- HeaderCharset := 'utf-8';
- HeaderEncoding := '8';
- end; // with
- IdHttp.Head('http://domain.com/data/my-file.zip');
- ByteRange := Http.Response.ContentLength;
- // TODO: Get the rest of the file that corresponds to [ByteRange-...]
- with Stream.AddFile('upload_file', FileName, 'application/octet-stream') do
- begin
- HeaderCharset := 'utf-8';
- HeaderEncoding := '8';
- end; // with
- PostStatus := Trim(IdHTTP.Post(POST_URL, Stream));
Advertisement
Add Comment
Please, Sign In to add comment