我有一个系统可以在 Delphi XE5 中通过 SSL 使用 FTP,但我打算切换到 Amazon S3。 我正在尝试制作一组简单的命令,用于设置参数、连接、将文件放入存储桶和断开连接。
现在我正在用 IDFTP 做这个
ftp := TIdFTP.Create();
ssl := TIdSSLIOHandlerSocketOpenSSL.Create(ftp);
ftp.IOHandler := ssl;
ssl.SSLOptions.Method := sslvSSLv23;
ftp.UseTLS := utUseExplicitTLS;
ftp.Host := 'myftpserver.com';
ftp.Username := 'user';
ftp.Password := 'password';
ftp.Passive := true;
ftp.Connect;
ftp.ChangeDir(destinefolder);
for i := 1 to3 do
begin //upload file1.jpg, file2.jpg, file3.jpg
ftp.put (local + ‘file’ + inttostr(i) + ’.jpg’ , ‘file’ + inttostr(i), true, false);
end;
ssl.Free;
ftp.Free;
它适用于 FTPS。
我听说有人说可以为 Amazon S3 使用 IDhttp。
我想知道是否有一种简单的方法可以使我的 ftps 适应 amazon s3。
最佳答案
基于 AWS 文档:
Authenticating a Request in the Authorization Header
试试这个:
Auth := '...'; // calculate/format based on Access Key Id Secret Access Key...
for i := 1 to 3 do
begin
FS := TFileStream.Create(local + 'file' + inttostr(i) + '.jpg', fmOpenRead or fmShareDenyWrite);
try
IdHTTP1.Request.CustomHeaders.Values['Authorization'] := Auth;
IdHTTP1.Request.BasicAuthentication := False;
IdHTTP1.Request.Date := ...;
IdHTTP1.Request.Expect := '100-continue';
IdHTTP1.Request.ProtocolVersion := pv1_1;
// other headers as needed...
...
IdHTTP1.Put('http://'+BucketName+'.s3.amazonaws.com/file' + inttostr(i), FS);
finally
FS.Free;
end;
end;
关于amazon-web-services - 从 ftp ssl 到 Amazon S3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27219538/