December 31st, 2012, 11:53 AM
Join Date: Dec 2012
Time spent in forums: 3 m 49 sec
Reputation Power: 0
Problem with Indy fIdHttp.put method
i need to upload files to Amazon S3 so i use fIdHttp.put method from fIdHttp Indy Component
fIdHttp.post is not allowed by the server...
during the upload i need to display time needed and a progress bar showing the percentual.
to manage progress bar during upload i have defined:
fIdHttp.OnWorkBegin := IdHTTP1WorkBegin;
fIdHttp.OnWorkEnd := IdHTTP1WorkEnd;
fIdHttp.OnWork := IdHTTP1Work;
then i call the procedure for upload...
SetAuthorization (Id_HTTPMethodPut, '', contentType, '', BucketNormal (BucketName) + Name);
fIdHttp.Put (BucketUrl (BucketName) + Name, fStr);
the program enter into procedure IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64) until AworkCount >= filesize
and then IdHTTP1WorkEnd (ASender: TObject; AWorkMode: TWorkMode) is fired...
the progress bar is 100% but in reality fIdHttp.post has not finished his work....the upload is still running and terminate after
variable time depending the size of the file. At the end the file is correctly uploaded...
so... my application believe the upload is terminated but this is not true... the upload is still working...
this problem dont happens with download method fIdHttp.get.. the OnWork method is fired when the single stream is received so the progress bar goes right...
i work on Delphi XE2