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

Is there any use in writing a file locally first before calling write_civis_file? #211

Closed
crich011 opened this issue Sep 3, 2019 · 3 comments

Comments

@crich011
Copy link

crich011 commented Sep 3, 2019

I have a utility function which takes an object as an argument and outputs a file ID on S3, much like write_civis_file (which it calls under the hood after first writing the given file locally). Is there any utility to this? I feel like the reason I did it this way is just that someone's code who I inherited did it that way for powerpoint documents, rather than there being a particularly good reason.

The resolution to this issue might just be an answer of "no, it is not useful".

@patr1ckm
Copy link
Contributor

patr1ckm commented Sep 4, 2019

If I understand correctly, write_civis_file(obj) already does this. It serializes the file, and returns the file id on S3 after uploading. I don't think a wrapper is needed.

One thing I can imagine is that it can be slightly annoying to save and cleanup objects in temporary files. We have a utility with_tempfile for doing so. Maybe exporting would be helpful?

For example:

with_tempfile(function(fn, obj) { 
  saveRDS(fn)
  write_civis_file(fn)
})

@crich011
Copy link
Author

crich011 commented Sep 4, 2019

Makes sense! Maybe surfacing that tempfile utility would be useful? But I defer to you on that; happy to close this issue if you're not especially keen on surfacing with_tempfile.

@patr1ckm
Copy link
Contributor

patr1ckm commented Sep 4, 2019

Since this is already a function in http://withr.r-lib.org/reference/with_tempfile.html, I doubt exporting will gain very much.

@patr1ckm patr1ckm closed this as completed Sep 4, 2019
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