@@ -105,20 +105,35 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {
105
105
const streamFilePath = payload['{{ parameter .name }}'];
106
106
let id = undefined;
107
107
108
+ let counter = 0;
108
109
const totalCounters = Math.ceil(size / libClient.CHUNK_SIZE);
109
110
110
- for (let counter = 0; counter < totalCounters; counter++) {
111
- const start = (counter * libClient.CHUNK_SIZE);
112
- const end = Math.min((((counter * libClient.CHUNK_SIZE) + libClient.CHUNK_SIZE) - 1), size);
113
- const headers = {
111
+ const headers = {
114
112
{% for parameter in method .parameters .header %}
115
- '{{ parameter .name }}': ${{ parameter .name | caseCamel | escapeKeyword }},
113
+ '{{ parameter .name }}': ${{ parameter .name | caseCamel | escapeKeyword }},
116
114
{% endfor %}
117
115
{% for key , header in method .headers %}
118
- '{{ key }}': '{{ header }}',
116
+ '{{ key }}': '{{ header }}',
117
+ {% endfor %}
118
+ };
119
+
120
+ {% for parameter in method .parameters .all %}
121
+ {% if parameter .isUploadID %}
122
+ if({{ parameter .name | caseCamel | escapeKeyword }} != 'unique()') {
123
+ try {
124
+ response = await client.call('get', path + '/' + {{ parameter .name }}, headers);
125
+ counter = response.chunksUploaded;
126
+ } catch(e) {
127
+ }
128
+ }
129
+ {% endif %}
119
130
{% endfor %}
120
- 'content-range': 'bytes ' + start + '-' + end + '/' + size
121
- };
131
+
132
+ for (counter; counter < totalCounters; counter++) {
133
+ const start = (counter * libClient.CHUNK_SIZE);
134
+ const end = Math.min((((counter * libClient.CHUNK_SIZE) + libClient.CHUNK_SIZE) - 1), size);
135
+
136
+ headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
122
137
123
138
if (id) {
124
139
headers['x-appwrite-id'] = id;
0 commit comments