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

Getting error when saving a dataframe #76

Closed
MilesAheadAlso opened this issue Sep 27, 2017 · 2 comments
Closed

Getting error when saving a dataframe #76

MilesAheadAlso opened this issue Sep 27, 2017 · 2 comments

Comments

@MilesAheadAlso
Copy link

I suspect it is something that I have not configured correctly, but I cannot see what it might be. My code is below:

options(googleAuthR.scopes.selected = "https://www.googleapis.com/auth/devstorage.full_control")
googleAuthR::gar_auth()
proj <- "xyz-r-forecasting"
bucket <- "xyz-r-forecast"
buckets <- gcs_list_buckets(proj)  #Returns correct result
bucket_info <- gcs_get_bucket(bucket)  #Returns correct result
objects <- gcs_list_objects(bucket)   #Returns correct result
gcs_save(RRPayLoad, file = "RRPayLoad", bucket = gcs_get_bucket(bucket), envir = parent.frame())
#Returns error below

The last statement returns the error below.

Request Status Code: 411
Error : lexical error: invalid char in json text.
                                       <!DOCTYPE html> <html lang=en> 
                     (right here) ------^

Error: lexical error: invalid char in json text.
                                       <!DOCTYPE html> <html lang=en> 
                     (right here) ------^
In addition: Warning message:
No JSON content found in request

The dataframe RRPayLoad is below.

  Offset Method    Category     ForecastItem       Date Forecast
1      6   BSTS Statistical 1001936040|NE_US 2017-07-01        0
2      6   BSTS Statistical 1001936040|NE_US 2017-08-01        0
3      6   BSTS Statistical 1001936040|NE_US 2017-09-01        0
4      6   BSTS Statistical 1001936040|NE_US 2017-10-01        0
5      6   BSTS Statistical 1001936040|NE_US 2017-11-01        0
6      6   BSTS Statistical 1001936040|NE_US 2017-12-01        0
@MarkEdmondson1234
Copy link
Collaborator

Ah, you're looking for gcs_upload instead. gcs_save is for uploading an R object as produced by save(). You're not the first though to do this, may put in a warning message :)

@MarkEdmondson1234
Copy link
Collaborator

Also, I expected to send in a character vector of your bucket name for argument:

gcs_save(RRPayLoad, file = "RRPayLoad", bucket = "my-bucket-name")

Although I can see it makes sense to take a bucket object too.

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

2 participants