Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/gcp/storage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Readable } from "stream";
import * as path from "path";
import * as clc from "colorette";
import { getProject } from "../management/projects";

import { firebaseStorageOrigin, storageOrigin } from "../api";
import { Client } from "../apiv2";
Expand Down Expand Up @@ -116,7 +117,7 @@
];
};
labels: {
(key: any): string;

Check warning on line 120 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
};
storageClass: string;
billing: {
Expand Down Expand Up @@ -189,7 +190,7 @@
downloadTokens?: string;
}

export async function getDefaultBucket(projectId: string): Promise<string> {

Check warning on line 193 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
await ensure(projectId, firebaseStorageOrigin(), "storage", false);
try {
const localAPIClient = new Client({
Expand All @@ -205,9 +206,9 @@
"Your project is being set up. Please wait a minute before deploying again.",
);
}
return response.body.bucket.name.split("/").pop()!;

Check warning on line 209 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion
} catch (err: any) {

Check warning on line 210 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err?.status === 404) {

Check warning on line 211 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
throw new FirebaseError(
`Firebase Storage has not been set up on project '${clc.bold(
projectId,
Expand All @@ -219,8 +220,8 @@
}
}

export async function upload(

Check warning on line 223 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
source: any,

Check warning on line 224 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
uploadUrl: string,
extraHeaders?: Record<string, string>,
ignoreQuotaProject?: boolean,
Expand All @@ -237,7 +238,7 @@
"content-type": "application/zip",
...extraHeaders,
},
body: source.stream,

Check warning on line 241 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .stream on an `any` value

Check warning on line 241 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
skipLog: { resBody: true },
ignoreQuotaProject,
});
Expand Down Expand Up @@ -298,7 +299,7 @@
* Deletes an object via Firebase Storage.
* @param {string} location A Firebase Storage location, of the form "/v0/b/<bucket>/o/<object>"
*/
export function deleteObject(location: string): Promise<any> {

Check warning on line 302 in src/gcp/storage.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const localAPIClient = new Client({ urlPrefix: storageOrigin() });
return localAPIClient.delete(location);
}
Expand Down Expand Up @@ -369,7 +370,18 @@
req: CreateBucketRequest;
}): Promise<void> {
try {
await (exports as { getBucket: typeof getBucket }).getBucket(opts.req.name);
const bucketResponse = await (exports as { getBucket: typeof getBucket }).getBucket(
opts.req.name,
);
const projectMetadata = await getProject(opts.projectId);
if (
!bucketResponse.projectNumber ||
bucketResponse.projectNumber !== projectMetadata.projectNumber
) {
throw new FirebaseError(
"There is already an existing bucket that belongs to another project.",
);
}
return;
} catch (err) {
const errStatus = getErrStatus((err as FirebaseError).original);
Expand Down
Loading