Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download directly from MinIO from R Shiny #3

Open
david-wavrock opened this issue Nov 20, 2020 · 0 comments
Open

Download directly from MinIO from R Shiny #3

david-wavrock opened this issue Nov 20, 2020 · 0 comments

Comments

@david-wavrock
Copy link

david-wavrock commented Nov 20, 2020

This was posted on slack already but at Blair's request I am posting it here

Download daaas_storage.R which serves as a workaround for accessing MinIO files using the R package aws.s3 and put it in the same shiny folder as the server, ui and global files.

In the global file, include:

library(aws.s3)

source('~/project_folder/shiny/daaas_storage.R')
daaas_storage.minimal()

minio_filist <- get_bucket(bucket='shared', use_https=FALSE, region='', prefix='your-name/.../minio-project_folder/')

The character string for prefix should link to the folder where files are stored which you wish to download via the shiny app. minio_filist is of class s3_bucket.

In the server file, include:

output$downloadFile <- downloadHandler(
    filename = 'download.zip'

    content = function(filename){
        save_object('your-name/.../minio-project_folder/target_file.zip',bucket=minio_filist,
        use_https=FALSE, region='',
        file=filename)
    }
)

I found that I had to specify the full filepath from 'shared' in MinIO in order to get the download to work. 'download.zip' is the default name for which the file will be saved and is passed as an argument to the function specified in content.

Calling downloadFile in your ui file occurs as normal:

downloadButton('downloadFile','Download')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant