嘗試檢測添加到Web服務器中的最新文件的名稱的正確方法是什麼?我試圖使用Indy HTTPS下載文件。文件名是動態生成的,所以我首先需要確定服務器上存在的最新文件的名稱是什麼。Delphi Indy HTTPS從Web服務器檢測最新文件
我用下面的代碼從Web服務器下載文件:
function getIndyFile_from_https(const fileURL, FileName: String): boolean;
var http:TIdHttp;
s:TFileStream;
i:integer;
FProgress: Integer;
FBytesToTransfer: Int64;
FOnChange: TNotifyEvent;
IOHndl: TIdSSLIOHandlerSocketOpenSSL;
protocol_url,fullurl,url_fara_protocol,host:string;
begin
http:=TIdHTTP.Create(nil);
IOHndl := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
http.Request.BasicAuthentication := True;
//Request.Accept:='text/html,*/*';
//Request.AcceptEncoding:='utf-8';
http.HandleRedirects := True;
http.IOHandler := IOHndl;
http.ReadTimeout := 30000;
//http.OnWork := HTTPWork;
//http.OnWorkBegin := HTTPWorkBegin;
//http.OnWorkEnd := HTTPWorkEnd;
try
s:=TFileStream.Create(filename, fmcreate);
try
http.Get(fileUrl,s);
result:=true;
finally
s.free;
end;
finally
http.Free;
end;
end;
謝謝您確認我的假設。 – user2858981