Actually Download File from S3 bucket to local machine

Discussão em 'Angular' iniciado por Banani720, Março 26, 2025.

  1. Banani720

    Banani720 Guest

    I am trying to get an s3 file from my bucket using the following function:

    async Export()
    {
    const myKey = '...key...'
    const mySecret = '...secret...'
    AWS.config.update(
    {
    accessKeyId: myKey,
    secretAccessKey: mySecret
    }
    );

    var s3 = new AWS.S3();

    s3.getObject({
    Bucket: '...bucket...',
    Key: '...filepath...'
    },
    function(error, data)
    {
    if (error != null)
    {
    alert("Failed to retrieve object: " + error)
    }
    else {
    alert("Loaded " + data.ContentLength + " bytes")
    }
    })
    }


    and the message telling me that I have loaded a file of some number of bytes. However, the main goal is to get the file onto my local machine, would I need to have some sort of file stream going on here or something?

    Notes


    Using angular typescript not angular js

    Continue reading...

Compartilhe esta Página