Skip to content

fix: pong response & chunked upload #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions appwrite/client.py
Original file line number Diff line number Diff line change
@@ -13,11 +13,11 @@ def __init__(self):
self._endpoint = 'https://cloud.appwrite.io/v1'
self._global_headers = {
'content-type': '',
'user-agent' : 'AppwritePythonSDK/7.1.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
'user-agent' : 'AppwritePythonSDK/8.0.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
'x-sdk-name': 'Python',
'x-sdk-platform': 'server',
'x-sdk-language': 'python',
'x-sdk-version': '7.1.0',
'x-sdk-version': '8.0.0',
'X-Appwrite-Response-Format' : '1.6.0',
}

@@ -79,7 +79,7 @@ def call(self, method, path='', headers=None, params=None, response_type='json')
data = {}
files = {}
stringify = False

headers = {**self._global_headers, **headers}

if method != 'get':
@@ -170,12 +170,11 @@ def chunked_upload(
offset = 0
counter = 0

if upload_id != 'unique()':
try:
result = self.call('get', path + '/' + upload_id, headers)
counter = result['chunksUploaded']
except:
pass
try:
result = self.call('get', path + '/' + upload_id, headers)
counter = result['chunksUploaded']
except:
pass

if counter > 0:
offset = counter * self._chunk_size
@@ -188,7 +187,7 @@ def chunked_upload(
if offset + self._chunk_size < size:
end = offset + self._chunk_size
else:
end = size - offset
end = size
input_file.data = input[offset:end]

params[param_name] = input_file
@@ -200,10 +199,10 @@ def chunked_upload(
headers,
params,
)

offset = offset + self._chunk_size
if "$id" in result:

if "$id" in result:
headers["x-appwrite-id"] = result["$id"]

if on_progress is not None:
@@ -229,7 +228,7 @@ def flatten(self, data, prefix='', stringify=False):
finalKey = prefix + '[' + key +']' if prefix else key
finalKey = prefix + '[' + str(i) +']' if isinstance(data, list) else finalKey
i += 1

if isinstance(value, list) or isinstance(value, dict):
output = {**output, **self.flatten(value, finalKey, stringify)}
else:
@@ -239,4 +238,3 @@ def flatten(self, data, prefix='', stringify=False):
output[finalKey] = value

return output

1 change: 1 addition & 0 deletions appwrite/enums/image_format.py
Original file line number Diff line number Diff line change
@@ -6,4 +6,5 @@ class ImageFormat(Enum):
GIF = "gif"
PNG = "png"
WEBP = "webp"
HEIC = "heic"
AVIF = "avif"
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
'appwrite/encoders',
'appwrite/enums',
],
version = '7.1.0',
version = '8.0.0'
license='BSD-3-Clause',
description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API',
long_description = long_description,
@@ -23,7 +23,7 @@
maintainer = 'Appwrite Team',
maintainer_email = '[email protected]',
url = 'https://appwrite.io/support',
download_url='https://github.com/appwrite/sdk-for-python/archive/7.1.0.tar.gz',
download_url='https://github.com/appwrite/sdk-for-python/archive/8.0.0.tar.gz',
install_requires=[
'requests',
],