MCPcopy Index your code
hub / github.com/callstack/agent-device / uploadBrowserStackApp

Function uploadBrowserStackApp

src/cloud-webdriver/browserstack.ts:160–184  ·  view source on GitHub ↗
(
  appPath: string,
  options: BrowserStackUploadOptions,
)

Source from the content-addressed store, hash-verified

158};
159
160export async function uploadBrowserStackApp(
161 appPath: string,
162 options: BrowserStackUploadOptions,
163): Promise<string> {
164 const file = await fs.readFile(appPath);
165 const form = new FormData();
166 form.set('file', new Blob([file]), path.basename(appPath));
167 const response = await fetch(options.endpoint ?? BROWSERSTACK_APP_UPLOAD_ENDPOINT, {
168 method: 'POST',
169 headers: {
170 ...agentDeviceRequestHeaders(),
171 Authorization: basicAuthHeader(options),
172 },
173 body: form,
174 });
175 const json = (await response.json()) as unknown;
176 const appUrl = readBrowserStackAppUrl(json);
177 if (!response.ok || !appUrl) {
178 throw new AppError('COMMAND_FAILED', 'BrowserStack app upload failed.', {
179 status: response.status,
180 response: json,
181 });
182 }
183 return appUrl;
184}
185
186export function createBrowserStackUploadApp(
187 options: Required<BrowserStackUploadOptions>,

Calls 4

basicAuthHeaderFunction · 0.90
readBrowserStackAppUrlFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected