@google-cloud/storage#FileExistsResponse TypeScript Examples
The following examples show how to use
@google-cloud/storage#FileExistsResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: googleStorage.ts From backstage with Apache License 2.0 | 6 votes |
/**
* A helper function which checks if index.html of an Entity's docs site is available. This
* can be used to verify if there are any pre-generated docs available to serve.
*/
async hasDocsBeenGenerated(entity: Entity): Promise<boolean> {
return new Promise(resolve => {
const entityTriplet = `${entity.metadata.namespace}/${entity.kind}/${entity.metadata.name}`;
const entityDir = this.legacyPathCasing
? entityTriplet
: lowerCaseEntityTriplet(entityTriplet);
const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);
this.storageClient
.bucket(this.bucketName)
.file(`${entityRootDir}/index.html`)
.exists()
.then((response: FileExistsResponse) => {
resolve(response[0]);
})
.catch(() => {
resolve(false);
});
});
}