@appium/support
Version:
Support libs used across Appium packages
61 lines • 2.47 kB
TypeScript
import { type Method } from 'axios';
import type { HTTPHeaders } from '@appium/types';
/** Common options for {@linkcode uploadFile} and {@linkcode downloadFile}. */
export interface NetOptions {
/** Whether to log the actual download performance (e.g. timings and speed). Defaults to true. */
isMetered?: boolean;
/** Authentication credentials */
auth?: AuthCredentials;
}
/** Basic auth credentials; used by {@linkcode NetOptions}. */
export interface AuthCredentials {
/** Non-empty user name (or use `username` for axios-style) */
user?: string;
/** Non-empty password (or use `password` for axios-style) */
pass?: string;
username?: string;
password?: string;
}
/** Specific options for {@linkcode downloadFile}. */
export interface DownloadOptions extends NetOptions {
/** Request timeout in milliseconds; defaults to {@linkcode DEFAULT_TIMEOUT_MS} */
timeout?: number;
/** Request headers mapping */
headers?: Record<string, unknown>;
}
/** Options for {@linkcode uploadFile} when the remote uses the `http(s)` protocol. */
export interface HttpUploadOptions extends NetOptions {
/** Additional request headers */
headers?: HTTPHeaders;
/** HTTP method for file upload. Defaults to 'POST'. */
method?: Method;
/** Request timeout in milliseconds; defaults to {@linkcode DEFAULT_TIMEOUT_MS} */
timeout?: number;
/**
* Name of the form field containing the file. Any falsy value uses non-multipart upload.
* Defaults to 'file'.
*/
fileFieldName?: string;
/**
* Additional form fields. Only considered if `fileFieldName` is set.
*/
formFields?: Record<string, unknown> | [string, unknown][];
}
/**
* Options for {@linkcode uploadFile} when the remote uses the `ftp` protocol.
*/
export interface FtpUploadOptions extends NetOptions {
}
/** @deprecated Use {@linkcode FtpUploadOptions} instead. */
export type NotHttpUploadOptions = FtpUploadOptions;
/**
* Uploads the given file to a remote location. HTTP(S) and FTP protocols are supported.
*/
export declare function uploadFile(localPath: string, remoteUri: string, uploadOptions?: HttpUploadOptions | FtpUploadOptions): Promise<void>;
/**
* Downloads the given file via HTTP(S).
*
* @throws {Error} If download operation fails
*/
export declare function downloadFile(remoteUrl: string, dstPath: string, downloadOptions?: DownloadOptions): Promise<void>;
//# sourceMappingURL=net.d.ts.map