Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 18.0.0

* Add `<REGION>` to doc examples due to the new multi region endpoints
* Add `<REGION>` to doc examples due to the new multi region endpoints
* Remove `Gif` from ImageFormat enum
* Remove `search` param from `listExecutions` method
* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite Web SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-web.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/databases/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setAdmin('') //
.setSession('') // The user session to authenticate with
.setKey('') //
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
Expand Down
18 changes: 18 additions & 0 deletions docs/examples/databases/decrement-document-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.decrementDocumentAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<DOCUMENT_ID>', // documentId
'', // attribute
null, // value (optional)
null // min (optional)
);

console.log(result);
18 changes: 18 additions & 0 deletions docs/examples/databases/increment-document-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.incrementDocumentAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<DOCUMENT_ID>', // documentId
'', // attribute
null, // value (optional)
null // max (optional)
);

console.log(result);
7 changes: 4 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,9 @@ class Client {
}

async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
const file = Object.values(originalPayload).find((value) => value instanceof File);
const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];

if (!file) {
if (!file || !fileParam) {
throw new Error('File not found in payload');
}

Expand All @@ -701,7 +701,8 @@ class Client {
headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;
const chunk = file.slice(start, end);

let payload = { ...originalPayload, file: new File([chunk], file.name)};
let payload = { ...originalPayload };
payload[fileParam] = new File([chunk], file.name);

response = await this.call(method, url, headers, payload);

Expand Down
1 change: 1 addition & 0 deletions src/enums/image-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export enum ImageFormat {
Webp = 'webp',
Heic = 'heic',
Avif = 'avif',
Gif = 'gif',
}
Loading