本文整理汇总了TypeScript中cuid类的典型用法代码示例。如果您正苦于以下问题:TypeScript cuid类的具体用法?TypeScript cuid怎么用?TypeScript cuid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cuid类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: returnScreenshot
// Returns the S3 url or local file path
async returnScreenshot(): Promise<string> {
const data = await screenshot(this.client)
// check if S3 configured
if (process.env['CHROMELESS_S3_BUCKET_NAME'] && process.env['CHROMELESS_S3_BUCKET_URL']) {
const s3Path = `${cuid()}.png`
const s3 = new AWS.S3()
await s3.putObject({
Bucket: process.env['CHROMELESS_S3_BUCKET_NAME'],
Key: s3Path,
ContentType: 'image/png',
ACL: 'public-read',
Body: new Buffer(data, 'base64'),
}).promise()
return `https://${process.env['CHROMELESS_S3_BUCKET_URL']}/${s3Path}`
}
// write to `/tmp` instead
else {
const filePath = `/tmp/${cuid()}.png`
fs.writeFileSync(filePath, Buffer.from(data, 'base64'))
return filePath
}
}
开发者ID:KhaledNobani,项目名称:chromeless,代码行数:27,代码来源:local-runtime.ts
示例2: returnPdf
// Returns the S3 url or local file path
async returnPdf(options?: PdfOptions): Promise<string> {
const data = await pdf(this.client, options)
// check if S3 configured
if (
process.env['CHROMELESS_S3_BUCKET_NAME'] &&
process.env['CHROMELESS_S3_BUCKET_URL']
) {
const s3Path = `${cuid()}.pdf`
const s3 = new AWS.S3()
await s3
.putObject({
Bucket: process.env['CHROMELESS_S3_BUCKET_NAME'],
Key: s3Path,
ContentType: 'application/pdf',
ACL: 'public-read',
Body: new Buffer(data, 'base64'),
})
.promise()
return `https://${process.env['CHROMELESS_S3_BUCKET_URL']}/${s3Path}`
} else {
// write to `${os.tmpdir()}` instead
const filePath = path.join(os.tmpdir(), `${cuid()}.pdf`)
fs.writeFileSync(filePath, Buffer.from(data, 'base64'))
return filePath
}
}
开发者ID:xw616525957,项目名称:chromeless,代码行数:30,代码来源:local-runtime.ts
示例3: async
export default async (event, context, callback): Promise<void> => {
const url = createPresignedURL()
const channelId = cuid()
callback(null, {
statusCode: 200,
body: JSON.stringify({ url, channelId }),
})
}
开发者ID:13768324554,项目名称:chromeless,代码行数:9,代码来源:session.ts
示例4: writeToFile
export function writeToFile(
data: string,
extension: string,
filePathOverride: string,
): string {
const filePath =
filePathOverride || path.join(os.tmpdir(), `${cuid()}.${extension}`)
fs.writeFileSync(filePath, Buffer.from(data, 'base64'))
return filePath
}
开发者ID:13768324554,项目名称:chromeless,代码行数:10,代码来源:util.ts
示例5: uploadToS3
export async function uploadToS3(data: string, contentType: string): Promise<string> {
const s3ContentType = s3ContentTypes[contentType]
if (!s3ContentType) {
throw new Error(`Unknown S3 Content type ${contentType}`)
}
const s3Path = `${getS3ObjectKeyPrefix()}${cuid()}.${s3ContentType.extension}`
const s3 = new AWS.S3()
await s3
.putObject({
Bucket: getS3BucketName(),
Key: s3Path,
ContentType: contentType,
ACL: 'public-read',
Body: Buffer.from(data, 'base64'),
})
.promise()
return `https://${getS3BucketUrl()}/${s3Path}`
}
开发者ID:nylen,项目名称:chromeless,代码行数:19,代码来源:util.ts
示例6:
const getPingUrl = (region: string) => `${getDynamoUrl(region)}/ping?x=${cuid()}`
开发者ID:sadeeqaji,项目名称:graphcool-cli,代码行数:1,代码来源:ping.ts
注:本文中的cuid类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论