MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / toFile

Function toFile

packages/core/http/http-request/index.ios.ts:26–40  ·  view source on GitHub ↗
(this: BaseHttpContent, destinationFilePath?: string)

Source from the content-addressed store, hash-verified

24 return this.toNativeImage().then((value) => new ImageSource(value));
25 },
26 toFile(this: BaseHttpContent, destinationFilePath?: string) {
27 if (!destinationFilePath) {
28 destinationFilePath = getFilenameFromUrl(this.requestURL);
29 }
30 if (this.raw instanceof NSData) {
31 // ensure destination path exists by creating any missing parent directories
32 const file = File.fromPath(destinationFilePath);
33
34 this.raw.writeToFileAtomically(destinationFilePath, true);
35
36 return file;
37 } else {
38 throw new Error(`Cannot save file with path: ${destinationFilePath}.`);
39 }
40 },
41};
42
43export function request(options: HttpRequestOptions): Promise<HttpResponse> {

Callers

nothing calls this directly

Calls 2

getFilenameFromUrlFunction · 0.90
fromPathMethod · 0.45

Tested by

no test coverage detected