找到了:
uses IdMultipartFormData
...
Stream: TIdMultipartFormDataStream;
已编辑:
对于 Jira REST API 的这个特殊问题,解决方案类似于:
针对 URL 发布:BASE_URL+/rest/api/2/issue/{issueIdOrKey}/attachments
try
lHTTP.Request.CustomHeaders.AddValue('X-Atlassian-Token', 'nocheck');
FileSize := lHTTP.Response.ContentLength;
FileStrm := TFileStream.Create(AFile, fmOpenRead or fmShareDenyWrite);
try
if FileSize < FileStrm.Size then
begin
FileStrm.Position := FileSize;
Stream := TIdMultipartFormDataStream.Create;
try
Stream.AddFile('file', AFile);
with lHTTP do
begin
with Request do
begin
ContentRangeStart := FileSize + 1;
ContentRangeEnd := FileStrm.Size;
end;
Post(self.BASE_URL + SEND_ATTACHEMENT_TO_AN_ISSUE_URL +
IntToStr(IssueID) + '/attachments', Stream);
Result := true;
end;
finally
Stream.Free;
end;
end;
finally
FileStrm.Free;
end;
except
Result := false;
end;
注意:之后不要忘记改回标题并将“内容类型”更改为未来请求所需的类型