Skip to content

SYNO.Fotos APU #2

@jaimetur

Description

@jaimetur

Hi Jessica. I followed you because the research job that you did 5 years ago with Synology PhotoStation API is amazing.

Now, 5 years later, I am currently in the same point where you were 5 years ago, I mean, I'm looking for a way to easily upload all my assets extracted from Google Photos (through Google Takeout) into the renewed app Synology Photos (replacement of Synology PhotoStation). I have done a deep research on the web but there is no neither official nor unofficial API to do read. So in the same way that you did with Wishark I did with Chrome Code Inspector and tried to guess how the new API works but unfortunately I still have some issues making work the API SYNO.Foto.Upload.Item with the method upload.

I was wondering if perhaps you may have updated documentation about this or maybe you can help to make the following code work as expected:

Any support that you can offer to me is more than welcome.

Thanks again in advance.

'''
import os
import mimetypes
import requests

file_path = "path/to/file.jpg"

if not os.path.exists(file_path):
raise FileNotFoundError(f"El archivo '{file_path}' no existe.")

stats = os.stat(file_path)
mime_type = mimetypes.guess_type(file_path)[0] or 'application/octet-stream'

synology_url = "https://tu-synology.com/webapi/entry.cgi"

payload = {
'api': 'SYNO.Foto.Upload.Item',
'method': 'upload',
'version': '1',
'name': os.path.basename(file_path),
'uploadDestination': 'timeline',
'duplicate': 'ignore',
'mtime': str(int(stats.st_mtime)),
'folder': '["PhotoLibrary"]'
}

files = {
'file': (os.path.basename(file_path), open(file_path, 'rb'), mime_type)
}

response = requests.post(synology_url, data=payload, files=files)

print(response.status_code, response.text)
'''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions