cloudyr / aws.s3

Amazon Simple Storage Service (S3) API Client
https://cloud.r-project.org/package=aws.s3
381 stars 147 forks source link

put_object error: Argument object must be of type character or raw vector #425

Open msmith1695 opened 1 year ago

msmith1695 commented 1 year ago

Encountering an error while using the put_object function while attempting a basic CSV file upload to S3 via R, using the aws.s3 package. Code:

library(aws.s3)
library(tcltk)

Sys.setenv(
  "AWS_ACCESS_KEY_ID" = "xxxxxxxxxxxxxxxxxxxx",
  "AWS_SECRET_ACCESS_KEY" = "xxxxxxxxxxxxxxxxxxxx",
  "AWS_DEFAULT_REGION" = "us-east-1"
)

file_to_upload <- read.csv(tk_choose.files(caption = "Choose CSV file to upload"))

put_object(file = file_to_upload,
           object = "test.csv",
           bucket = "bucket_name",
           folder = "folder_name",
           )

Which results in an error message of:

Error: Argument object must be of type character or raw vector if serialize is FALSE

With the verbose = TRUE parameter included in the function call, output is:

Locating credentials Checking for credentials in user-supplied values Checking for credentials in Environment Variables Using Environment Variable 'AWS_ACCESS_KEY_ID' for AWS Access Key ID Using Environment Variable 'AWS_SECRET_ACCESS_KEY' for AWS Secret Access Key Using Environment Variable 'AWS_DEFAULT_REGION' for AWS Region ('us-east-1') S3 Request URL: https://s3.amazonaws.com/bucket_name/folder_name/test.csv Executing request with AWS credentials Locating credentials Checking for credentials in user-supplied values Using user-supplied value for AWS Access Key ID Using user-supplied value for AWS Secret Access Key Using user-supplied value for AWS Region ('us-east-1') Error: Argument object must be of type character or raw vector if serialize is FALSE

This seems closely related to Issue #243.