本文整理汇总了TypeScript中builder-util/out/nodeHttpExecutor.httpExecutor.download方法的典型用法代码示例。如果您正苦于以下问题:TypeScript httpExecutor.download方法的具体用法?TypeScript httpExecutor.download怎么用?TypeScript httpExecutor.download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类builder-util/out/nodeHttpExecutor.httpExecutor
的用法示例。
在下文中一共展示了httpExecutor.download方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: downloadCertificate
export async function downloadCertificate(urlOrBase64: string, tmpDir: TmpDir, currentDir: string): Promise<string> {
urlOrBase64 = urlOrBase64.trim()
let file: string | null = null
if ((urlOrBase64.length > 3 && urlOrBase64[1] === ":") || urlOrBase64.startsWith("/") || urlOrBase64.startsWith(".")) {
file = urlOrBase64
}
else if (urlOrBase64.startsWith("file://")) {
file = urlOrBase64.substring("file://".length)
}
else if (urlOrBase64.startsWith("~/")) {
file = path.join(homedir(), urlOrBase64.substring("~/".length))
}
else {
const isUrl = urlOrBase64.startsWith("https://")
if (isUrl || urlOrBase64.length > 2048 || urlOrBase64.endsWith("=")) {
const tempFile = await tmpDir.getTempFile({suffix: ".p12"})
if (isUrl) {
await httpExecutor.download(urlOrBase64, tempFile)
}
else {
await outputFile(tempFile, Buffer.from(urlOrBase64, "base64"))
}
return tempFile
}
else {
file = urlOrBase64
}
}
file = path.resolve(currentDir, file)
const stat = await statOrNull(file)
if (stat == null) {
throw new Error(`${file} doesn't exist`)
}
else if (!stat.isFile()) {
throw new Error(`${file} not a file`)
}
else {
return file
}
}
示例2: async
test.ifAll.ifDevOrLinuxCi("download to nonexistent dir", async () => {
const tempFile = await tmpDir.getTempFile()
await httpExecutor.download("https://drive.google.com/uc?export=download&id=0Bz3JwZ-jqfRONTkzTGlsMkM2TlE", tempFile)
await assertThat(tempFile).isFile()
})