six_file_upload | R Documentation |
Magically upload a file
six_file_upload(path, bucket, force = FALSE, ...)
path |
(character) one or more file paths to add to
the |
bucket |
(character) bucket to copy files to. required. if the bucket does not exist we prompt you asking if you'd like the bucket to be created |
force |
(logical) force bucket creation without going through
the prompt. default: |
... |
named params passed on to put_object |
(character) a vector of remote s3 paths where your files are located
Exits early if files do not exist
Exits early if any path
values are directories
Creates the bucket if it does not exist
Adds files to the bucket, figuring out the key to use from the supplied path
Function is vectoried for the path
argument; you can
pass in many file paths
Other files:
aws_file_attr()
,
aws_file_copy()
,
aws_file_delete()
,
aws_file_download()
,
aws_file_exists()
,
aws_file_rename()
,
aws_file_upload()
Other magicians:
six_admin_setup()
,
six_bucket_delete()
,
six_bucket_upload()
,
six_user_create()
,
six_user_delete()
bucket1 <- random_bucket()
demo_rds_file <- file.path(system.file(), "Meta/demo.rds")
six_file_upload(demo_rds_file, bucket1, force = TRUE)
# path doesn't exist, error
try(
six_file_upload("file_doesnt_exist.txt", random_bucket())
)
# directories not supported, error
mydir <- tempdir()
try(
six_file_upload(mydir, random_bucket())
)
# Cleanup
six_bucket_delete(bucket1, force = TRUE)
# requires user interaction with prompts ...
bucket2 <- random_bucket()
demo_rds_file <- file.path(system.file(), "Meta/demo.rds")
six_file_upload(demo_rds_file, bucket2)
## many files at once
links_file <- file.path(system.file(), "Meta/links.rds")
six_file_upload(c(demo_rds_file, links_file), bucket2)
# set expiration, expire 1 minute from now
six_file_upload(demo_rds_file, bucket2, Expires = Sys.time() + 60)
# bucket doesn't exist, ask if you want to create it
not_a_bucket <- random_string("not-a-bucket-")
six_file_upload(demo_rds_file, not_a_bucket)
# Cleanup
six_bucket_delete(bucket2, force = TRUE)
six_bucket_delete(not_a_bucket, force = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.