Data Import uploadData API – Automating through GCS & App Engine app

I’d like to automate the process of Data Import to Google Analytics, so that every night raw CSVs uploaded to Google Cloud Storage > my app reads these files and make data import to Google Analytics

I believe this could be achieved through App Engine app:

  • running nightly cron job, to read data CSVs from GCS
  • and potentially using uploadData Management APImanagement/uploads/uploadData to make Data Import POST

but the problem i encounter is:: the Python client library for uploadData API only accepts file name to upload data:

media = MediaFileUpload('custom_data.csv',mimetype,resumable=False)
daily_upload =, webPropertyId, customDataSourceId, media_body).execute()

Whereas App Engine app doesn’t have any persistent disk where it can read file from (I tried to insert GCS Bucket name instead of File name, but it doesn’t work)

Any suggestions how I could automate the process? or am I on right track..?

Thanks a lot for any clue.. I’m stuck here 🙂


The client library and the api do not require that it be a file. Its only your MediaFileUpload that does You should be able to create a media uploader that takes a stream. the documentation mentions its possible