Reputation: 1476
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:
POST https://www.googleapis.com/upload/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customDataSources/customDataSourceId/uploads
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 = analytics.management().uploads().uploadData(accountId, 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 :)
Upvotes: 2
Views: 395
Reputation: 117281
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
https://developers.google.com/api-client-library/python/guide/media_upload#extending-mediaupload
Upvotes: 1