1
Read a file from S3 within a script (Bun)
One script reply has been approved by the moderators Verified
Created by henri186 268 days ago Viewed 8313 times
0
Submitted by henri186 Bun
Verified 268 days ago
1
// Details on S3 integration at https://www.windmill.dev/docs/core_concepts/persistent_storage/large_data_files
2

3
import * as wmill from 'windmill-client';
4
import { S3Object } from 'windmill-client';
5

6
export async function main(input_file: S3Object) {
7
	// Load the entire file_content as a Uint8Array
8
	const file_content = await wmill.loadS3File(input_file);
9

10
	const decoder = new TextDecoder();
11
	const file_content_str = decoder.decode(file_content);
12
	console.log(file_content_str);
13

14
	// Or load the file lazily as a Blob
15
	let fileContentBlob = await wmill.loadS3FileStream(input_file);
16
	console.log(await fileContentBlob.text());
17
}