Edits history of script submission #254 for ' Get recently updated objects (s3)'

  • deno
    One script reply has been approved by the moderators
    Ap­pro­ved
    import {
      getState,
      setState,
    } from "https://deno.land/x/[email protected]/mod.ts";
    import { S3Client } from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Tested on 10 000 objects, which got processed in 2.3-2.6 seconds.
     */
    type S3 = {
      endPoint: string;
      port: number;
      useSSL: boolean;
      pathStyle: boolean;
      bucket: string;
      accessKey: string;
      secretKey: string;
      region: string;
    };
    export async function main(s3: S3, bucket?: string) {
      const client = new S3Client(s3);
      const generator = client.listObjects({
        bucketName: bucket || undefined,
      });
    
      const lastCheck = (await getState()) || 0;
      await setState(Date.now());
      const newlyUpdated = [];
    
      while (true) {
        const obj = await generator.next();
        if (obj.done) break;
    
        const lastMod = new Date(obj.value.lastModified).getTime();
        if (lastMod > lastCheck) {
          newlyUpdated.push(obj.value);
        }
      }
    
      return newlyUpdated;
    }
    

    Submitted by hugo697 376 days ago

  • deno
    import {
      getState,
      setState,
    } from "https://deno.land/x/[email protected]/mod.ts";
    import { S3Client } from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Tested on 10 000 objects, which got processed in 2.3-2.6 seconds.
     */
    type S3 = {
      endPoint: string;
      port: number;
      useSSL: boolean;
      pathStyle: boolean;
      bucket: string;
      accessKey: string;
      secretKey: string;
      region: string;
    };
    export async function main(s3: S3, bucket?: string) {
      const client = new S3Client(s3);
      const generator = client.listObjects({
        bucketName: bucket || undefined,
      });
    
      const lastCheck = (await getState()) || 0;
      await setState(Date.now());
      const newlyUpdated = [];
    
      while (true) {
        const obj = await generator.next();
        if (obj.done) break;
    
        const lastMod = new Date(obj.value.lastModified).getTime();
        if (lastMod > lastCheck) {
          newlyUpdated.push(obj.value);
        }
      }
    
      return newlyUpdated;
    }
    

    Submitted by admin 1009 days ago

  • deno
    import { getState, setState } from "https://deno.land/x/[email protected]/mod.ts";
    import { S3Client } from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Tested on 10 000 objects, which got processed in 2.3-2.6 seconds.
     */
    type S3 = {
      endPoint: string;
      port: number;
      useSSL: boolean;
      pathStyle: boolean;
      bucket: string;
      accessKey: string;
      secretKey: string;
      region: string;
    };
    export async function main(
      s3: S3,
      bucket?: string
    ) {
      const client = new S3Client(s3);
      const generator = client.listObjects({
        bucketName: bucket || undefined
      });
    
      const lastCheck = await getState() || 0;
      await setState(Date.now());
      const newlyUpdated = [];
    
      while(true) {
        const obj = await generator.next();
        if(obj.done) break;
    
        const lastMod = new Date(obj.value.lastModified).getTime()
        if(lastMod > lastCheck) {
          newlyUpdated.push(obj.value);
        }
      }
    
      return newlyUpdated;
    }
    

    Submitted by admin 1012 days ago

  • deno
    import { Resource, getState, setState } from "https://deno.land/x/[email protected]/mod.ts";
    import { S3Client } from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Tested on 10 000 objects, which got processed in 2.3-2.6 seconds.
     */
    export async function main(
      s3: Resource<"s3">,
      bucket?: string
    ) {
      const client = new S3Client(s3);
      const generator = client.listObjects({
        bucketName: bucket || undefined
      });
    
      const lastCheck = await getState() || 0;
      await setState(Date.now());
      const newlyUpdated = [];
    
      while(true) {
        const obj = await generator.next();
        if(obj.done) break;
    
        const lastMod = new Date(obj.value.lastModified).getTime()
        if(lastMod > lastCheck) {
          newlyUpdated.push(obj.value);
        }
      }
    
      return newlyUpdated;
    }
    

    Submitted by adam186 1140 days ago

  • deno
    import { Resource, getState, setState } from "https://deno.land/x/[email protected]/mod.ts";
    import { S3Client } from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Tested on 10 000 objects, which got processed in 2.3-2.6 seconds.
     */
    export async function main(
      s3: Resource<"s3">,
      bucket?: string
    ) {
      const client = new S3Client(s3);
      const generator = client.listObjects({
        bucketName: bucket || undefined
      });
    
      const lastCheck = await getState() || 0;
      await setState(Date.now());
      const newlyUpdated = [];
    
      while(true) {
        const obj = await generator.next();
        if(obj.done) break;
    
        const lastMod = new Date(obj.value.lastModified).getTime()
        if(lastMod > lastCheck) {
          newlyUpdated.push(obj.value);
        }
      }
    
      return newlyUpdated;
    }
    

    Submitted by adam186 1175 days ago

  • deno
    import { Resource, getState, setState } from "https://deno.land/x/[email protected]/mod.ts";
    import { S3Client } from "https://deno.land/x/[email protected]/mod.ts";
    
    /**
     * Tested on 10 000 objects, which got processed in 2.3-2.6 seconds.
     */
    export async function main(
      s3: Resource<"s3">,
      bucket?: string
    ) {
      const client = new S3Client(s3);
      const generator = client.listObjects({
        bucketName: bucket || undefined
      });
    
      const lastCheck = await getState() || 0;
      await setState(Date.now());
      const newlyUpdated = [];
    
      while(true) {
        const obj = await generator.next();
        if(obj.done) break;
    
        const lastMod = new Date(obj.value.lastModified).getTime()
        if(lastMod > lastCheck) {
          newlyUpdated.push(obj.value);
        }
      }
    
      return newlyUpdated;
    }
    

    Submitted by adam186 1244 days ago

  • deno
    import { Resource, getState, setState } from "https://deno.land/x/[email protected]/mod.ts";
    import { S3Client } from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
      s3: Resource<"s3">,
      bucket?: string
    ) {
      const client = new S3Client(s3);
      const generator = client.listObjects({
        bucketName: bucket || undefined
      });
    
      const lastCheck = await getState() || 0;
      await setState(Date.now())
      const newlyUpdated = [];
    
      while(true) {
        const obj = await generator.next();
        if(obj.done) break;
    
        const lastMod = new Date(obj.value.lastModified).getTime()
        if(lastMod > lastCheck) {
          newlyUpdated.push(obj.value)
        }
      }
    
      return newlyUpdated
    }
    

    Submitted by adam186 1244 days ago