还看到了另一个与Indy有关的示例,因此,请帮助使用以下这些项构建授权标头:SecretAccessKey,SessionToken,Expiration,AccessKeyId.可以采用单块传输净荷"模式+签名净荷选项". FS := TFileStream.Create('c:\myfile.txt', fmOpenRead or fmShareDenyWrite); try IdHTTP1.Request.CustomHeaders.Values['Authorization'] := ...; // please help IdHTTP1.Request.BasicAuthentication := False; IdHTTP1.Request.Date := ...; //what should I enter here? IdHTTP1.Request.Expect := '100-continue'; IdHTTP1.Request.ProtocolVersion := pv1_1; ... IdHTTP1.Put('http://'+BucketName+'.s3.amazonaws.com/myfile.txt', FS); finally FS.Free; end;谢谢!解决方案这是我使用Cloud Components将文件上传到Amazon的例程:function UploadFile(File: TBytes; FileName: string; Bucket: string): boolean;var Service: TAmazonStorageService; ConAmazon: TAmazonConnectionInfo;begin try ConAmazon := TAmazonConnectionInfo.Create(nil); ConAmazon.AccountKey := 'Dih71bG09****************'; ConAmazon.AccountName := 'AKIA***********'; ConAmazon.QueueEndpoint := 'queue.amazonaws.com'; ConAmazon.StorageEndpoint := 's3-eu-west-1.amazonaws.com'; ConAmazon.TableEndpoint := 'sdb.amazonaws.com'; ConAmazon.UseDefaultEndpoints := False; Service := TAmazonStorageService.Create(ConAmazon); Result := Service.UploadObject(Bucket, FileName, File, TRUE, nil, nil, amzbaPrivate, nil); finally ConAmazon.Free; Service.Free; end;end;I have an AWS S3 account and got SecretAccessKey, SessionToken, Expiration, AccessKeyId items. I would like to upload some files to the cloud, in the simplest way. Have read a some docs regarding authorization headers (http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html) but still do not understand how to build them)) also, saw another example with Indy, so, please help to build the authorization header with these items that I have: SecretAccessKey, SessionToken, Expiration, AccessKeyId. It's ok to be with a "Transferring Payload in a Single Chunk" mode + "Signed payload option". FS := TFileStream.Create('c:\myfile.txt', fmOpenRead or fmShareDenyWrite); try IdHTTP1.Request.CustomHeaders.Values['Authorization'] := ...; // please help IdHTTP1.Request.BasicAuthentication := False; IdHTTP1.Request.Date := ...; //what should I enter here? IdHTTP1.Request.Expect := '100-continue'; IdHTTP1.Request.ProtocolVersion := pv1_1; ... IdHTTP1.Put('http://'+BucketName+'.s3.amazonaws.com/myfile.txt', FS); finally FS.Free; end;Thank you! 解决方案 Here's my routine to upload files to Amazon using the Cloud Components:function UploadFile(File: TBytes; FileName: string; Bucket: string): boolean;var Service: TAmazonStorageService; ConAmazon: TAmazonConnectionInfo;begin try ConAmazon := TAmazonConnectionInfo.Create(nil); ConAmazon.AccountKey := 'Dih71bG09****************'; ConAmazon.AccountName := 'AKIA***********'; ConAmazon.QueueEndpoint := 'queue.amazonaws.com'; ConAmazon.StorageEndpoint := 's3-eu-west-1.amazonaws.com'; ConAmazon.TableEndpoint := 'sdb.amazonaws.com'; ConAmazon.UseDefaultEndpoints := False; Service := TAmazonStorageService.Create(ConAmazon); Result := Service.UploadObject(Bucket, FileName, File, TRUE, nil, nil, amzbaPrivate, nil); finally ConAmazon.Free; Service.Free; end;end; 这篇关于使用临时安全凭证将文件上传到带有Delphi的Amazon S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-20 17:17