import {
getState,
setState,
} from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { S3Client } from "https://deno.land/x/s3_lite_client@0.3.0/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 497 days ago
import { getState, setState } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { S3Client } from "https://deno.land/x/s3_lite_client@0.3.0/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 500 days ago
import { Resource, getState, setState } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { S3Client } from "https://deno.land/x/s3_lite_client@0.3.0/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 628 days ago
import { Resource, getState, setState } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { S3Client } from "https://deno.land/x/s3_lite_client@0.3.0/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 663 days ago
import { Resource, getState, setState } from "https://deno.land/x/windmill@v1.55.0/mod.ts";
import { S3Client } from "https://deno.land/x/s3_lite_client@0.3.0/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 732 days ago
import { Resource, getState, setState } from "https://deno.land/x/windmill@v1.55.0/mod.ts";
import { S3Client } from "https://deno.land/x/s3_lite_client@0.3.0/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 732 days ago