question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uploading a file with google photos API

See original GitHub issue

Hi, I am trying to upload image, video via photoslibrary v1 API. But I am not getting how to upload? There are no demos and no clear documentation upon how to do it?

from googleapiclient.discovery import build
service = build('photoslibrary', 'v1', credentials=credentials)

It does not have API with for MediaFileUpload https://developers.google.com/api-client-library/python/guide/media_upload

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
wasdeecommented, Apr 28, 2019

I do using requests.

import requests
headers = {
    'Content-Type': "application/octet-stream",
    'X-Goog-Upload-File-Name': "line-586.jpg",
    'X-Goog-Upload-Protocol': "raw",
    'Authorization': "Bearer " + creds.access_token,
    }
data = open('image.jpg', 'rb').read()
response = requests.post('https://photoslibrary.googleapis.com/v1/uploads', headers=headers, data=data)
image_token = response.text
1reaction
busunkim96commented, Apr 29, 2019

Hello! The photos API is maintained separately. Here is their support page. The Photos API has Java and PHP client libraries, but not one for Python. You can interact with the Photos REST API via requests in Python.

If a Python client library is of interest, it may be worth putting in a feature request. There is more information on how to do that on the support page.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upload file data | Google Drive
The Drive API lets you upload file data when you create or update a File . For information about how to create a...
Read more >
Can upload photo when using the Google Photos API
using the new Google Photos API. I am able to get an uploadToken but when I try to create the media item I...
Read more >
Upload With The Google Photos API - Filestack Blog
Integrate the Google Photos API into your app to allow users to upload files directly from Google Photos without ever leaving your app....
Read more >
How to upload files with Google Photos API in 10 ... - Medium
To upload a file to Google Photos using its API, we have to make 2 different calls. First, you have to make call...
Read more >
eshmu/gphotos-upload - GitHub
Obtaining a Google Photos API key · Replace YOUR_CLIENT_ID in the client_id.json file with the provided Client ID. · Replace YOUR_CLIENT_SECRET in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found