amazon-web-services - 从 ftp ssl 到 Amazon S3

标签 amazon-web-services delphi ssl amazon-s3 ftp

我有一个系统可以在 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 文档:

PUT Object

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/

相关文章:

amazon-web-services - AWS ApiGateway VPC 链接与 HTTP 代理集成

amazon-web-services - AWS Cloudformation - 在 Fn::Sub 中使用 AWS::NoValue

apache - Hadoop 272 - Datanodes 启动然后停止

delphi - 修改exe资源中的字符串

Delphi - Firebird - Vista 访问套接字被拒绝

mysql - 用于频繁大于和小于查询的 SQL 表结构

multithreading - Delphi - OTL - ThreadPool 和 Worker 线程之间的通信

Apache2 mod_rewrite 基于 URI 匹配将 SSL 重定向到非 SSL,反之亦然

ssl - 生成 OpenSSL 证书时如何自动化 PEM 密码?

firefox - Firefox 16 中基于浏览器的 YouTube 上传意外中止