Skip to content

Commit 52fa4ef

Browse files
Merge pull request #1029 from appwrite/fix-file-ids
fix: file ids
2 parents f241c8a + 4cc0897 commit 52fa4ef

File tree

15 files changed

+81
-89
lines changed

15 files changed

+81
-89
lines changed

templates/android/library/src/main/java/io/package/Client.kt.twig

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Client @JvmOverloads constructor(
6060
internal lateinit var http: OkHttpClient
6161

6262
internal val headers: MutableMap<String, String>
63-
63+
6464
val config: MutableMap<String, String>
6565

6666
internal val cookieJar = ListenableCookieJar(CookieManager(
@@ -87,14 +87,14 @@ class Client @JvmOverloads constructor(
8787
"x-sdk-platform" to "{{ sdk.platform }}",
8888
"x-sdk-language" to "{{ language.name | caseLower }}",
8989
"x-sdk-version" to "{{ sdk.version }}"{% if spec.global.defaultHeaders | length > 0 %},{% endif %}
90-
90+
9191
{% for key,header in spec.global.defaultHeaders %}
9292
"{{ key | caseLower }}" to "{{ header }}"{% if not loop.last %},{% endif %}
9393
{% endfor %}
9494

9595
)
9696
config = mutableMapOf()
97-
97+
9898
setSelfSigned(selfSigned)
9999
}
100100

@@ -119,10 +119,10 @@ class Client @JvmOverloads constructor(
119119
{% endfor %}
120120
/**
121121
* Set self Signed
122-
*
122+
*
123123
* @param status
124124
*
125-
* @return this
125+
* @return this
126126
*/
127127
fun setSelfSigned(status: Boolean): Client {
128128
selfSigned = status
@@ -171,10 +171,10 @@ class Client @JvmOverloads constructor(
171171

172172
/**
173173
* Set endpoint and realtime endpoint.
174-
*
174+
*
175175
* @param endpoint
176176
*
177-
* @return this
177+
* @return this
178178
*/
179179
fun setEndpoint(endpoint: String): Client {
180180
this.endpoint = endpoint
@@ -200,11 +200,11 @@ class Client @JvmOverloads constructor(
200200

201201
/**
202202
* Add Header
203-
*
203+
*
204204
* @param key
205205
* @param value
206206
*
207-
* @return this
207+
* @return this
208208
*/
209209
fun addHeader(key: String, value: String): Client {
210210
headers[key] = value
@@ -232,19 +232,19 @@ class Client @JvmOverloads constructor(
232232

233233
/**
234234
* Send the HTTP request
235-
*
235+
*
236236
* @param method
237237
* @param path
238238
* @param headers
239239
* @param params
240240
*
241-
* @return [T]
241+
* @return [T]
242242
*/
243243
@Throws({{ spec.title | caseUcfirst }}Exception::class)
244244
suspend fun <T> call(
245-
method: String,
246-
path: String,
247-
headers: Map<String, String> = mapOf(),
245+
method: String,
246+
path: String,
247+
headers: Map<String, String> = mapOf(),
248248
params: Map<String, Any?> = mapOf(),
249249
responseType: Class<T>,
250250
converter: ((Any) -> T)? = null
@@ -382,7 +382,7 @@ class Client @JvmOverloads constructor(
382382
var offset = 0L
383383
var result: Map<*, *>? = null
384384

385-
if (idParamName?.isNotEmpty() == true && params[idParamName] != "unique()") {
385+
if (idParamName?.isNotEmpty() == true) {
386386
// Make a request to check if a file already exists
387387
val current = call(
388388
method = "GET",
@@ -479,14 +479,14 @@ class Client @JvmOverloads constructor(
479479
.charStream()
480480
.buffered()
481481
.use(BufferedReader::readText)
482-
482+
483483
val error = if (response.headers["content-type"]?.contains("application/json") == true) {
484484
val map = body.fromJson<Map<String, Any>>()
485485

486486
{{ spec.title | caseUcfirst }}Exception(
487-
map["message"] as? String ?: "",
487+
map["message"] as? String ?: "",
488488
(map["code"] as Number).toInt(),
489-
map["type"] as? String ?: "",
489+
map["type"] as? String ?: "",
490490
body
491491
)
492492
} else {
@@ -546,4 +546,4 @@ class Client @JvmOverloads constructor(
546546
}
547547
})
548548
}
549-
}
549+
}

templates/apple/Sources/Client.swift.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ open class Client {
387387
var offset = 0
388388
var result = [String:Any]()
389389

390-
if idParamName != nil && params[idParamName!] as! String != "unique()" {
390+
if idParamName != nil {
391391
// Make a request to check if a file already exists
392392
do {
393393
let map = try await call(

templates/dart/lib/src/client_browser.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
121121
}
122122

123123
var offset = 0;
124-
if (idParamName.isNotEmpty && params[idParamName] != 'unique()') {
124+
if (idParamName.isNotEmpty) {
125125
//make a request to check if a file already exists
126126
try {
127127
res = await call(

templates/dart/lib/src/client_io.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class ClientIO extends ClientBase with ClientMixin {
142142
}
143143

144144
var offset = 0;
145-
if (idParamName.isNotEmpty && params[idParamName] != 'unique()') {
145+
if (idParamName.isNotEmpty) {
146146
//make a request to check if a file already exists
147147
try {
148148
res = await call(

templates/deno/src/services/service.ts.twig

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
108108
{% if parameter.type == 'file' %}
109109

110110
const size = {{ parameter.name | caseCamel | escapeKeyword }}.size;
111-
111+
112112
const apiHeaders: { [header: string]: string } = {
113113
{% for parameter in method.parameters.header %}
114114
'{{ parameter.name }}': ${{ parameter.name | caseCamel | escapeKeyword }},
@@ -125,16 +125,14 @@ export class {{ service.name | caseUcfirst }} extends Service {
125125

126126
{% for parameter in method.parameters.all %}
127127
{% if parameter.isUploadID %}
128-
if({{ parameter.name | caseCamel | escapeKeyword }} != 'unique()') {
129-
try {
130-
response = await this.client.call(
131-
'get',
132-
apiPath + '/' + {{ parameter.name }},
133-
apiHeaders
134-
);
135-
chunksUploaded = response.chunksUploaded;
136-
} catch(e) {
137-
}
128+
try {
129+
response = await this.client.call(
130+
'get',
131+
apiPath + '/' + {{ parameter.name }},
132+
apiHeaders
133+
);
134+
chunksUploaded = response.chunksUploaded;
135+
} catch(e) {
138136
}
139137
{% endif %}
140138
{% endfor %}
@@ -160,7 +158,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
160158
}
161159

162160
let uploadableChunkTrimmed: Uint8Array;
163-
161+
164162
if(currentPosition + 1 >= Client.CHUNK_SIZE) {
165163
uploadableChunkTrimmed = uploadableChunk;
166164
} else {
@@ -241,4 +239,4 @@ export class {{ service.name | caseUcfirst }} extends Service {
241239
{% endif %}
242240
}
243241
{% endfor %}
244-
}
242+
}

templates/dotnet/Package/Client.cs.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ namespace {{ spec.title | caseUcfirst }}
374374
);
375375
}
376376

377-
if (!string.IsNullOrEmpty(idParamName) && (string)parameters[idParamName] != "unique()")
377+
if (!string.IsNullOrEmpty(idParamName))
378378
{
379379
try
380380
{

templates/flutter/lib/src/client_browser.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
142142
}
143143

144144
var offset = 0;
145-
if (idParamName.isNotEmpty && params[idParamName] != 'unique()') {
145+
if (idParamName.isNotEmpty) {
146146
//make a request to check if a file already exists
147147
try {
148148
res = await call(

templates/flutter/lib/src/client_io.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class ClientIO extends ClientBase with ClientMixin {
262262
}
263263

264264
var offset = 0;
265-
if (idParamName.isNotEmpty && params[idParamName] != 'unique()') {
265+
if (idParamName.isNotEmpty) {
266266
//make a request to check if a file already exists
267267
try {
268268
res = await call(

templates/go/client.go.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ func (client *Client) FileUpload(url string, headers map[string]interface{}, par
157157
numChunks++
158158
}
159159
var currentChunk int64 = 0
160-
if uploadId != "" && uploadId != "unique()" {
160+
if uploadId != "" {
161161
resp, err := client.Call("GET", url+"/"+uploadId, nil, nil)
162162
if err == nil {
163163
currentChunk = int64(resp.Result.(map[string]interface{})["chunksUploaded"].(float64))
164164
}
165165
}
166166

167167
if fileInfo.Size() <= client.ChunkSize {
168-
if uploadId != "" && uploadId != "unique()" {
168+
if uploadId != "" {
169169
headers["x-appwrite-id"] = uploadId
170170
}
171171
inputFile.Data = make([]byte, fileInfo.Size())
@@ -203,7 +203,7 @@ func (client *Client) FileUpload(url string, headers map[string]interface{}, par
203203
return nil, err
204204
}
205205
params[paramName] = inputFile
206-
if uploadId != "" && uploadId != "unique()" {
206+
if uploadId != "" {
207207
headers["x-appwrite-id"] = uploadId
208208
}
209209
totalSize := fileInfo.Size()

templates/kotlin/src/main/kotlin/io/appwrite/Client.kt.twig

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class Client @JvmOverloads constructor(
191191

192192
/**
193193
* Prepare the HTTP request
194-
*
194+
*
195195
* @param method
196196
* @param path
197197
* @param headers
@@ -286,7 +286,7 @@ class Client @JvmOverloads constructor(
286286
* @param headers
287287
* @param params
288288
*
289-
* @return [T]
289+
* @return [T]
290290
*/
291291
@Throws({{ spec.title | caseUcfirst }}Exception::class)
292292
suspend fun <T> call(
@@ -309,7 +309,7 @@ class Client @JvmOverloads constructor(
309309
* @param headers
310310
* @param params
311311
*
312-
* @return [T]
312+
* @return [T]
313313
*/
314314
@Throws({{ spec.title | caseUcfirst }}Exception::class)
315315
suspend fun redirect(
@@ -381,7 +381,7 @@ class Client @JvmOverloads constructor(
381381
var offset = 0L
382382
var result: Map<*, *>? = null
383383

384-
if (idParamName?.isNotEmpty() == true && params[idParamName] != "unique()") {
384+
if (idParamName?.isNotEmpty() == true) {
385385
// Make a request to check if a file already exists
386386
val current = call(
387387
method = "GET",
@@ -448,7 +448,7 @@ class Client @JvmOverloads constructor(
448448
return converter(result as Map<String, Any>)
449449
}
450450

451-
/**
451+
/**
452452
* Await Redirect
453453
*
454454
* @param request
@@ -475,14 +475,14 @@ class Client @JvmOverloads constructor(
475475
.charStream()
476476
.buffered()
477477
.use(BufferedReader::readText)
478-
478+
479479
val error = if (response.headers["content-type"]?.contains("application/json") == true) {
480480
val map = body.fromJson<Map<String, Any>>()
481481

482482
{{ spec.title | caseUcfirst }}Exception(
483-
map["message"] as? String ?: "",
483+
map["message"] as? String ?: "",
484484
(map["code"] as Number).toInt(),
485-
map["type"] as? String ?: "",
485+
map["type"] as? String ?: "",
486486
body
487487
)
488488
} else {
@@ -526,14 +526,14 @@ class Client @JvmOverloads constructor(
526526
.charStream()
527527
.buffered()
528528
.use(BufferedReader::readText)
529-
529+
530530
val error = if (response.headers["content-type"]?.contains("application/json") == true) {
531531
val map = body.fromJson<Map<String, Any>>()
532532

533533
{{ spec.title | caseUcfirst }}Exception(
534-
map["message"] as? String ?: "",
534+
map["message"] as? String ?: "",
535535
(map["code"] as Number).toInt(),
536-
map["type"] as? String ?: "",
536+
map["type"] as? String ?: "",
537537
body
538538
)
539539
} else {
@@ -591,4 +591,4 @@ class Client @JvmOverloads constructor(
591591
}
592592
})
593593
}
594-
}
594+
}

0 commit comments

Comments
 (0)