Updated SDKs
This commit is contained in:
parent
2e590007be
commit
e065a1a5a5
|
@ -5,7 +5,7 @@ sdk
|
|||
setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0);
|
||||
let promise = sdk.projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 1);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -5,7 +5,7 @@ sdk
|
|||
setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com');
|
||||
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -5,7 +5,7 @@ sdk
|
|||
setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 1);
|
||||
let promise = sdk.projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
14
app/sdks/js/docs/examples/storage/update-file.md
Normal file
14
app/sdks/js/docs/examples/storage/update-file.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
setProject('')
|
||||
setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.updateFile('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -2,7 +2,7 @@
|
|||
"name": "appwrite",
|
||||
"homepage": "https://appwrite.io/support",
|
||||
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)",
|
||||
"version": "v1.0.18",
|
||||
"version": "v1.0.19",
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "src/sdk.js",
|
||||
"repository": {
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
globalParams.push({key: key, value: value});
|
||||
};
|
||||
|
||||
addGlobalHeader('x-sdk-version', 'appwrite:javascript:v1.0.18');
|
||||
addGlobalHeader('x-sdk-version', 'appwrite:javascript:v1.0.19');
|
||||
addGlobalHeader('content-type', '');
|
||||
|
||||
/**
|
||||
|
@ -2328,6 +2328,34 @@
|
|||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Update File
|
||||
*
|
||||
* Update file by its unique ID. Only users with write permissions have access
|
||||
* to update this resource.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @param {string} folderId
|
||||
* @throws {Error}
|
||||
* @return {Promise} */
|
||||
updateFile: function(fileId, read = [], write = [], folderId = '') {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.put(path, {'content-type': 'application/json'},
|
||||
{
|
||||
'read': read,
|
||||
'write': write,
|
||||
'folderId': folderId
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete File
|
||||
*
|
||||
|
|
5
app/sdks/js/src/sdk.min.js
vendored
5
app/sdks/js/src/sdk.min.js
vendored
|
@ -1,5 +1,5 @@
|
|||
(function(window){window.Appwrite=function(){let config={endpoint:'https://appwrite.test/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index<params[p].length;index++){let param=params[p][index];str.push(encodeURIComponent(p+'[]')+"="+encodeURIComponent(param))}}else{str.push(encodeURIComponent(p)+"="+encodeURIComponent(params[p]))}}
|
||||
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:v1.0.18');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')}
|
||||
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:v1.0.19');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')}
|
||||
if(typeof path!=='string'){throw new Error('var path must be of type string')}
|
||||
if(typeof headers!=='object'){throw new Error('var headers must be of type object')}
|
||||
for(i=0;i<globalParams.length;i++){path=addParam(path,globalParams[i].key,globalParams[i].value)}
|
||||
|
@ -127,7 +127,8 @@ let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{proje
|
|||
if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"')}
|
||||
let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);return http.delete(path,{'content-type':'application/json'},{})}};let storage={listFiles:function(search='',limit=25,offset=0,orderType='ASC'){let path='/storage/files';return http.get(path,{'content-type':'application/json'},{'search':search,'limit':limit,'offset':offset,'orderType':orderType})},createFile:function(files,read=[],write=[],folderId=''){if(files===undefined){throw new Error('Missing required parameter: "files"')}
|
||||
let path='/storage/files';return http.post(path,{'content-type':'multipart/form-data'},{'files':files,'read':read,'write':write,'folderId':folderId})},getFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'content-type':'application/json'},{})},deleteFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'content-type':'application/json'},{})},updateFile:function(fileId,read=[],write=[],folderId=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);return http.put(path,{'content-type':'application/json'},{'read':read,'write':write,'folderId':folderId})},deleteFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);return http.delete(path,{'content-type':'application/json'},{})},getFileDownload:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}/download'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'content-type':'application/json'},{})},getFilePreview:function(fileId,width=0,height=0,quality=100,background='',output=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'content-type':'application/json'},{'width':width,'height':height,'quality':quality,'background':background,'output':output})},getFileView:function(fileId,as=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
|
|
|
@ -5,7 +5,7 @@ sdk
|
|||
setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0);
|
||||
let promise = sdk.projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 1);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -5,7 +5,7 @@ sdk
|
|||
setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com');
|
||||
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -5,7 +5,7 @@ sdk
|
|||
setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 1);
|
||||
let promise = sdk.projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
14
app/sdks/node/docs/examples/storage/update-file.md
Normal file
14
app/sdks/node/docs/examples/storage/update-file.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
setProject('')
|
||||
setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.updateFile('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -7,7 +7,7 @@ class Client {
|
|||
this.endpoint = 'https://appwrite.test/v1';
|
||||
this.headers = {
|
||||
'content-type': '',
|
||||
'x-sdk-version': 'appwrite:nodejs:v1.0.22',
|
||||
'x-sdk-version': 'appwrite:nodejs:v1.0.23',
|
||||
};
|
||||
this.selfSigned = false;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,30 @@ class Storage extends Service {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update File
|
||||
*
|
||||
* Update file by its unique ID. Only users with write permissions have access
|
||||
* to update this resource.
|
||||
*
|
||||
* @param string fileId
|
||||
* @param array read
|
||||
* @param array write
|
||||
* @param string folderId
|
||||
* @throws Exception
|
||||
* @return {}
|
||||
*/
|
||||
async updateFile(fileId, read = [], write = [], folderId = '') {
|
||||
let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return await this.client.call('put', path, {'content-type': 'application/json'},
|
||||
{
|
||||
'read': read,
|
||||
'write': write,
|
||||
'folderId': folderId
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete File
|
||||
*
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "node-appwrite",
|
||||
"homepage": "https://appwrite.io/support",
|
||||
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)",
|
||||
"version": "v1.0.22",
|
||||
"version": "v1.0.23",
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
|
|
@ -12,4 +12,4 @@ $client
|
|||
|
||||
$projects = new Projects($client);
|
||||
|
||||
$result = $projects->createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0);
|
||||
$result = $projects->createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 1);
|
|
@ -12,4 +12,4 @@ $client
|
|||
|
||||
$projects = new Projects($client);
|
||||
|
||||
$result = $projects->updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com');
|
||||
$result = $projects->updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com');
|
|
@ -12,4 +12,4 @@ $client
|
|||
|
||||
$projects = new Projects($client);
|
||||
|
||||
$result = $projects->updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 1);
|
||||
$result = $projects->updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0);
|
15
app/sdks/php/docs/examples/storage/update-file.md
Normal file
15
app/sdks/php/docs/examples/storage/update-file.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
use Appwrite\Client;
|
||||
use Appwrite\Services\Storage;
|
||||
|
||||
$client = new Client();
|
||||
|
||||
$client
|
||||
setProject('')
|
||||
setKey('')
|
||||
;
|
||||
|
||||
$storage = new Storage($client);
|
||||
|
||||
$result = $storage->updateFile('[FILE_ID]');
|
|
@ -48,6 +48,23 @@ GET https://appwrite.test/v1/storage/files/{fileId}
|
|||
| --- | --- | --- | --- |
|
||||
| fileId | string | **Required** File unique ID. | |
|
||||
|
||||
## Update File
|
||||
|
||||
```http request
|
||||
PUT https://appwrite.test/v1/storage/files/{fileId}
|
||||
```
|
||||
|
||||
** Update file by its unique ID. Only users with write permissions have access to update this resource. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| fileId | string | **Required** File unique ID. | |
|
||||
| read | array | An array of read permissions. [Learn more about permissions and roles](/docs/permissions). | [] |
|
||||
| write | array | An array of write permissions. [Learn more about permissions and roles](/docs/permissions). | [] |
|
||||
| folderId | string | Folder to associate files with. | |
|
||||
|
||||
## Delete File
|
||||
|
||||
```http request
|
||||
|
|
|
@ -37,7 +37,7 @@ class Client
|
|||
*/
|
||||
protected $headers = [
|
||||
'content-type' => '',
|
||||
'x-sdk-version' => 'appwrite:php:v1.0.5',
|
||||
'x-sdk-version' => 'appwrite:php:v1.0.6',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,6 +85,32 @@ class Storage extends Service
|
|||
], $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update File
|
||||
*
|
||||
* Update file by its unique ID. Only users with write permissions have access
|
||||
* to update this resource.
|
||||
*
|
||||
* @param string $fileId
|
||||
* @param array $read
|
||||
* @param array $write
|
||||
* @param string $folderId
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function updateFile($fileId, $read = [], $write = [], $folderId = '')
|
||||
{
|
||||
$path = str_replace(['{fileId}'], [$fileId], '/storage/files/{fileId}');
|
||||
$params = [];
|
||||
|
||||
$params['read'] = $read;
|
||||
$params['write'] = $write;
|
||||
$params['folderId'] = $folderId;
|
||||
|
||||
return $this->client->call(Client::METHOD_PUT, $path, [
|
||||
], $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete File
|
||||
*
|
||||
|
|
|
@ -42,6 +42,21 @@ class Storage(Service):
|
|||
return self.client.call('get', path, {
|
||||
}, params)
|
||||
|
||||
def update_file(self, file_id, readstring(4) ""[]""
|
||||
=[], writestring(4) ""[]""
|
||||
=[], folder_id=''):
|
||||
"""Update File"""
|
||||
|
||||
params = {}
|
||||
path = '/storage/files/{fileId}'
|
||||
path.replace('{fileId}', file_id)
|
||||
params['read'] = read
|
||||
params['write'] = write
|
||||
params['folderId'] = folder_id
|
||||
|
||||
return self.client.call('put', path, {
|
||||
}, params)
|
||||
|
||||
def delete_file(self, file_id):
|
||||
"""Delete File"""
|
||||
|
||||
|
|
|
@ -40,6 +40,20 @@ module Appwrite
|
|||
}, params);
|
||||
end
|
||||
|
||||
def update_file(file_id:, read: [], write: [], folder_id: '')
|
||||
path = '/storage/files/{fileId}'
|
||||
.gsub('{file_id}', file_id)
|
||||
|
||||
params = {
|
||||
'read': read,
|
||||
'write': write,
|
||||
'folderId': folder_id
|
||||
}
|
||||
|
||||
return @client.call('put', path, {
|
||||
}, params);
|
||||
end
|
||||
|
||||
def delete_file(file_id:)
|
||||
path = '/storage/files/{fileId}'
|
||||
.gsub('{file_id}', file_id)
|
||||
|
|
|
@ -38,7 +38,7 @@ $cli
|
|||
|
||||
$clients = [
|
||||
'php' => [
|
||||
'version' => 'v1.0.5',
|
||||
'version' => 'v1.0.6',
|
||||
'result' => __DIR__ . '/../sdks/php/',
|
||||
'gitURL' => 'https://github.com/appwrite/sdk-for-php.git',
|
||||
'gitRepo' => 'git@github.com:appwrite/sdk-for-php.git',
|
||||
|
@ -46,7 +46,7 @@ $cli
|
|||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
'js' => [
|
||||
'version' => 'v1.0.18',
|
||||
'version' => 'v1.0.19',
|
||||
'result' => __DIR__ . '/../sdks/js/',
|
||||
'gitURL' => 'https://github.com/appwrite/sdk-for-js.git',
|
||||
'gitRepo' => 'git@github.com:appwrite/sdk-for-js.git',
|
||||
|
@ -54,7 +54,7 @@ $cli
|
|||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
'node' => [
|
||||
'version' => 'v1.0.22',
|
||||
'version' => 'v1.0.23',
|
||||
'result' => __DIR__ . '/../sdks/node/',
|
||||
'gitURL' => 'https://github.com/appwrite/sdk-for-node.git',
|
||||
'gitRepo' => 'git@github.com:appwrite/sdk-for-node.git',
|
||||
|
|
Loading…
Reference in a new issue