(this: BaseHttpContent, destinationFilePath: string)
| 37 | return this.toNativeImage().then((value) => new ImageSource(value)); |
| 38 | }, |
| 39 | toFile(this: BaseHttpContent, destinationFilePath: string) { |
| 40 | if (!destinationFilePath) { |
| 41 | destinationFilePath = getFilenameFromUrl(this.requestURL); |
| 42 | } |
| 43 | let stream: java.io.FileOutputStream; |
| 44 | try { |
| 45 | // ensure destination path exists by creating any missing parent directories |
| 46 | const file = File.fromPath(destinationFilePath); |
| 47 | |
| 48 | const javaFile = new java.io.File(destinationFilePath); |
| 49 | stream = new java.io.FileOutputStream(javaFile); |
| 50 | stream.write((this.raw as java.io.ByteArrayOutputStream).toByteArray()); |
| 51 | |
| 52 | return file; |
| 53 | } catch (exception) { |
| 54 | throw new Error(`Cannot save file with path: ${destinationFilePath}.`); |
| 55 | } finally { |
| 56 | if (stream) { |
| 57 | stream.close(); |
| 58 | } |
| 59 | } |
| 60 | }, |
| 61 | }; |
| 62 | |
| 63 | export function request(options: HttpRequestOptions): Promise<HttpResponse> { |
nothing calls this directly
no test coverage detected