To upload a file to Platform you will need to access a version of our API client on a local machine with access to the file you’d like to upload (not from a Platform script or Notebook). Files of any type can be stored at the Civis files endpoint.
Note: Files created this way will automatically expire after 30 days.
From the Python Client call file_to_civis
Python code example of uploading a file and printing out the assigned file ID:
pip install civis
python
import civis
client = civis.APIClient()
file_id = civis.io.file_to_civis('file_location', 'file_name')
print(file_id) # this is the file ID you want
Python code example of uploading a binary file and printing out the assigned file ID:
pip install civis
python
import civis
client = civis.APIClient()
file_id=civis.io.file_to_civis(open('file_location', 'rb'), 'file_name')
print(file_id) # this is the file ID you want
From the R client call write_civis_file
R code example of uploading a file and printing out the assigned file ID:
file_id <- write_civis_file(path_to_file, name_of_file)
print(file_id) # this is the file ID you want
Comments
0 comments
Please sign in to leave a comment.