|
<< Click to Display Table of Contents >> Navigation: Classes > TIWAppCache > Methods > StreamToCacheFile |
SIGNATURE=IWAppCache.TIWAppCache.StreamToCacheFile@TObject@TStream@string@string@TCacheType
ETYPE=Method
Declaration:
Delphi: |
public class function StreamToCacheFile(aOwner: TObject; AStream: TStream; const aFileName: string; const aContentType: string; const aCacheType: TCacheType = ctOneTime): string; overload; |
C++: |
public: __fastcall String StreamToCacheFile(TObject * aOwner, TStr |
Description: Saves AStream to cache file. Temp filename should be specified
Parameters:
•Sender (TObject): May have one of these values
•If you are creating a Form cache file, Sender must be an instance of TIWForm class.
•If you are creating a Session cache file, Sender must be an instance of TIWApplication class, or TIWForm class
•If you are creating an Application cache file, this parameter is ignored, so NIL may be used.
•AStream (TStream): Stream whose content will be saved into the cache file.
•AContentType (string): Content type of the stream.
•ACacheType (TCacheType, default ctSession): Type of cache that will be used. See TCacheType definition.
Result: (string) Contains the URL of the cache file.
Example:
uses
IWAppCache, // TIWAppCache
IW.CacheStream, // needed because of ACacheType
Windows; // needed because of RT_RCDATA reference
procedure TIWForm6.IWAppFormCreate(Sender: TObject);
var
MyStream: TStream;
HRef: string;
xResName: string;
begin
xResName := 'MYIMAGEFILE';
// get the resource stream containing the image I want to show
MyStream := TResourceStream.Create(0, PChar(xResName), RT_RCDATA);
try
// then create a new cache file and save the image to it.
//This cache file will be "alive" during the whole user session (ACacheType = ctSession)
// this function returns the URL to the cache file.
// We could also use other methods of TIWAppCache
HRef := TIWAppCache.StreamToCacheFile(Self, MyStream, 'image/gif', ctSession);
// Set URL of IWImageFile1 with the value returned by TIWAppCache.StreamToCacheFile
IWImageFile1.ImageFile.URL := HRef;
finally
MyStream.Free;
end;
end;