mdbs99 / aws

Object Pascal implementation for Amazon S3
MIT License
75 stars 19 forks source link

add GetObject() #2

Closed freedaun closed 9 years ago

freedaun commented 10 years ago

Hi Marcos, the title says it all. Abraço.

freedaun commented 10 years ago

Hi Marcos, I am under pressure and I need to have this feature by the 21th. So I did this and it seems to work:

function TAWSS3Client.GetObject(const ABucket, AObjectName: string; AStream: TStream): Integer; begin FHTTP.Clear; SetAuthHeader('GET', '', '', '', '/' + ABucket + '/' + AObjectName); Result := Send('GET', ABucket, '/' + AObjectName); FHTTP.Document.SaveToStream(AStream); // needs error checking?? end;

function TAWSS3Client.GetObject(const ABucket, AObjectName, AFileName: string): Integer; var Buf: TFileStream; begin Buf := TFileStream.Create(AFileName, fmCreate); try Result := GetObject(ABucket, AObjectName, Buf); // above if result <> 200 then deleteFile(AFilename); finally Buf.Free; end; end;

What worries me most is the SaveToStream part: it has no error checking.

mdbs99 commented 9 years ago

Done in bef9a7fcc87136429be6c290af54e5ee5df523eb