Edits history of script submission #8881 for ' Create Bucket (gcloud)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { Storage } from "@google-cloud/storage";
    
    type Gcloud = {
      type: string;
      project_id: string;
      private_key_id: string;
      private_key: string;
      client_email: string;
      client_id: string;
      auth_uri: string;
      token_uri: string;
      auth_provider_x509_cert_url: string;
      client_x509_cert_url: string;
      universe_domain: string;
    };
    
    export async function main(
      resource: Gcloud,
      bucketName: string,
      metadata?: {
        location?: string;
        storageClass?: "STANDARD" | "NEARLINE" | "COLDLINE" | "ARCHIVE";
      }
    ) {
      const storageClient = new Storage({
        credentials: resource,
        projectId: resource.project_id,
      });
    
      const [bucket] = await storageClient.createBucket(bucketName, metadata);
    
      return bucket.metadata;
    }
    

    Submitted by hugo697 692 days ago

  • bun
    import { Storage } from "@google-cloud/storage";
    
    type Gcloud = {
      type: string;
      project_id: string;
      private_key_id: string;
      private_key: string;
      client_email: string;
      client_id: string;
      auth_uri: string;
      token_uri: string;
      auth_provider_x509_cert_url: string;
      client_x509_cert_url: string;
      universe_domain: string;
    };
    
    export async function main(
      resource: Gcloud,
      bucketName: string,
      metadata?: {
        location?: string;
        storageClass?: "STANDARD" | "NEARLINE" | "COLDLINE" | "ARCHIVE";
      }
    ) {
      const storageClient = new Storage({
        credentials: resource,
        projectId: resource.project_id,
      });
    
      const [bucket] = await storageClient.createBucket(bucketName, metadata);
    
      return bucket.metadata;
    }
    

    Submitted by hugo697 693 days ago

  • bun
    import { Storage } from '@google-cloud/storage'
    
    type Gcloud = {
    	projectId: string
    	privateKey: string
    	clientEmail: string
    }
    
    export async function main(
    	resource: Gcloud,
    	bucketName: string,
    	metadata?: {
    		location?: string
    		storageClass?: 'STANDARD' | 'NEARLINE' | 'COLDLINE' | 'ARCHIVE'
    	}
    ) {
    	const credentials = {
    		client_email: resource.clientEmail,
    		private_key: resource.privateKey.replace(/\\n/g, '\n')
    	}
    
    	const storageClient = new Storage({ credentials, projectId: resource.projectId })
    
    	const [bucket] = await storageClient.createBucket(bucketName, metadata)
    
    	return bucket.metadata
    }
    

    Submitted by hugo697 693 days ago