0

Read a file from S3 within a script (Deno)

by
Published Mar 12, 2024

Details on S3 integration at https://www.windmill.dev/docs/core_concepts/persistent_storage/large_data_files

Script s3
  • Submitted by henri186 Deno
    Created 832 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 'npm:[email protected]';
    4
    import S3Object from 'npm:[email protected]';
    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
    }