cache
Learn more about using this API here
The sos.offline
API groups together methods used to download and save arbitrary files, which can be accessed even if the device is offline.
Emulator has certain limitations while handling offline files. Read more here
Methods
decompressFile()
The decompressFile()
decompresses the file specified by uid
into a new file specified by destinationUid
.
decompressFile(uid: string, destinationUid: string, method: 'zip'): Promise<void>;
Possible errors
The method throws an error if the uid does not exist.
deleteContent()
Learn more about using this API here
The deleteContent() method removes the value specified by
uid` key.
deleteContent(uid: string): Promise<void>;
deleteFile()
The deleteFile()
method removes the file specified by uid
.
deleteFile(uid: string): Promise<void>;
Possible errors
The method throws an error if the uid does not exist.
getChecksumFile()
The getChecksumFile()
computes a checksum of the file specified by uid
.
getChecksumFile(uid: string, hashType: HashAlgorithm): Promise<string>;
Possible errors
The method throws an error if the uid does not exist or the hashing algorithm is not supported.
listContents()
Learn more about using this API here
The listContent()
method lists all values saved by saveContent()
method.
listContents(): Promise<string[]>;
listFiles()
The listFiles()
method list all currently cached files.
listFiles(): Promise<string[]>;
loadContent()
Learn more about using this API here
The loadContent()
method gets the value specified by uid
, which was previously saved by saveContent()
.
loadContent(uid: string): Promise<string>;
loadFile()
The loadFile()
method loads cached file, which was previously saved by saveFile()
or loadOrSaveFile()
methods.
loadFile(uid: string): Promise<IFile>;
Possible errors
The method throws an error if the uid does not exists
loadOrSaveFile()
The loadOrSaveFile() method loads the file from the cache, or downloads it if it's not already cached.
loadOrSaveFile(uid: string, uri: string, headers?: {
[key: string]: string;
}): Promise<IFile>;
saveContent()
Learn more about using this API here
The saveContent()
method saves a string value to the cache.
saveContent(uid: string, content: string): Promise<void>;
saveFile()
The saveFile()
method downloads file from uri
and saves it to the offline cache.
uid
should have the same file extension (e.g.: mp4, svg, jpg) as the original file.
saveFile(uid: string, uri: string, headers?: {
[key: string]: string;
}): Promise<void>;
Possible errors
The method throws an error if the network request fails or a file with the same uid is already cached
validateChecksumFile()
The validateChecksumFile()
method validates whether the file, specified by uid
, has the correct checksum.
validateChecksumFile(uid: string, hash: string, hashType: HashAlgorithm): Promise<boolean>;
Possible errors
The method throws an error if the uid does not exist or the hashing algorithm is not supported.