【发布时间】:2017-01-19 21:52:25
【问题描述】:
我正在尝试使用 Indy 10 和 XE8 将文件上传到 Dropbox。虽然像'file.txt'这样的文件名可以正常工作,但使用'файл.txt'左右,我在DropBox上有'????.txt'。我阅读了有关 utf-8 的参数,但它不适用于标头:-(。
如何上传文件并保存 utf-8 文件名?
procedure TSaveFilterForm.TestButtonClick(Sender: TObject);
const
URL = 'https://content.dropboxapi.com/2/files/upload';
var
IdHTTP: TIdHTTP;
Source: TFileStream;
Res: String;
begin
IdHTTP := TIdHTTP.Create(nil);
try
IdHTTP.HandleRedirects := True;
IdHTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(IdHTTP);
IdHTTP.Request.BasicAuthentication := False;
IdHTTP.Request.CustomHeaders.Values['Authorization'] := 'Bearer ' + AccessToken;
IdHTTP.Request.ContentType := 'application/octet-stream';
Source := TFileStream.Create('c:\test.txt', fmOpenRead);
IdHTTP.Request.CustomHeaders.Values['Dropbox-API-Arg'] :=
Format('{ "path": "%s", "mode": "overwrite"}',
['/файл.txt']); // Dropbox => ????.txt
try
Res := IdHTTP.Post(URL, Source);
finally
Source.Free;
end;
finally
IdHTTP.Free;
end;
end;
【问题讨论】:
标签: delphi dropbox indy delphi-2009 indy10