@@ -116,58 +116,58 @@ export class {{ service.name | caseUcfirst }} extends Service {
116
116
{% for parameter in method .parameters .all %}
117
117
{% if parameter .isUploadID %}
118
118
if({{ parameter .name | caseCamel | escapeKeyword }} != 'unique()') {
119
- try {
120
- response = await this.client.call('get', path + '/' + {{ parameter .name }}, headers);
121
- counter = response.chunksUploaded;
122
- } catch(e) {
123
- }
119
+ try {
120
+ response = await this.client.call('get', path + '/' + {{ parameter .name }}, headers);
121
+ counter = response.chunksUploaded;
122
+ } catch(e) {
123
+ }
124
124
}
125
125
{% endif %}
126
126
{% endfor %}
127
127
128
128
for (counter; counter < totalCounters; counter++) {
129
- const start = (counter * Client.CHUNK_SIZE);
130
- const end = Math.min((((counter * Client.CHUNK_SIZE) + Client.CHUNK_SIZE) - 1), size);
131
-
132
- headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
133
-
134
- if (id) {
135
- headers['x-{{spec .title | caseLower }}-id'] = id;
136
- }
137
-
138
- const totalBuffer = new Uint8Array(Client.CHUNK_SIZE);
139
-
140
- for (let blockIndex = 0; blockIndex < Client.CHUNK_SIZE / Client.DENO_READ_CHUNK_SIZE; blockIndex++) {
141
- const buf = new Uint8Array(Client.DENO_READ_CHUNK_SIZE);
142
- const cursorPosition = await Deno.seek(stream.rid, start + (blockIndex * 16384), Deno.SeekMode.Start);
143
- const numberOfBytesRead = await Deno.read(stream.rid, buf);
144
-
145
- if (!numberOfBytesRead) {
146
- break;
147
- }
148
-
149
- for (let byteIndex = 0; byteIndex < Client.DENO_READ_CHUNK_SIZE; byteIndex++) {
150
- totalBuffer[(blockIndex * Client.DENO_READ_CHUNK_SIZE) + byteIndex] = buf[byteIndex];
151
- }
152
- }
153
-
154
- payload['{{ parameter .name }}'] = new File([totalBuffer], basename({{ parameter .name | caseCamel | escapeKeyword }}));
155
-
156
- response = await this.client.call('{{ method .method | caseLower }}', path, headers, payload{% if method .type == ' location' %}, 'arraybuffer'{% endif %});
157
-
158
- if (!id) {
159
- id = response['$id'];
129
+ const start = (counter * Client.CHUNK_SIZE);
130
+ const end = Math.min((((counter * Client.CHUNK_SIZE) + Client.CHUNK_SIZE) - 1), size);
131
+
132
+ headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
133
+
134
+ if (id) {
135
+ headers['x-{{spec .title | caseLower }}-id'] = id;
136
+ }
137
+
138
+ const totalBuffer = new Uint8Array(Client.CHUNK_SIZE);
139
+
140
+ for (let blockIndex = 0; blockIndex < Client.CHUNK_SIZE / Client.DENO_READ_CHUNK_SIZE; blockIndex++) {
141
+ const buf = new Uint8Array(Client.DENO_READ_CHUNK_SIZE);
142
+ const cursorPosition = await Deno.seek(stream.rid, start + (blockIndex * 16384), Deno.SeekMode.Start);
143
+ const numberOfBytesRead = await Deno.read(stream.rid, buf);
144
+
145
+ if (!numberOfBytesRead) {
146
+ break;
160
147
}
161
148
162
- if (onProgress !== null) {
163
- onProgress({
164
- $id: response['$id'],
165
- progress: Math.min((counter+1) * Client.CHUNK_SIZE, size) / size * 100,
166
- sizeUploaded: end+1,
167
- chunksTotal: response['chunksTotal'],
168
- chunksUploaded: response['chunksUploaded']
169
- });
149
+ for (let byteIndex = 0; byteIndex < Client.DENO_READ_CHUNK_SIZE; byteIndex++) {
150
+ totalBuffer[(blockIndex * Client.DENO_READ_CHUNK_SIZE) + byteIndex] = buf[byteIndex];
170
151
}
152
+ }
153
+
154
+ payload['{{ parameter .name }}'] = new File([totalBuffer], basename({{ parameter .name | caseCamel | escapeKeyword }}));
155
+
156
+ response = await this.client.call('{{ method .method | caseLower }}', path, headers, payload{% if method .type == ' location' %}, 'arraybuffer'{% endif %});
157
+
158
+ if (!id) {
159
+ id = response['$id'];
160
+ }
161
+
162
+ if (onProgress !== null) {
163
+ onProgress({
164
+ $id: response['$id'],
165
+ progress: Math.min((counter+1) * Client.CHUNK_SIZE, size) / size * 100,
166
+ sizeUploaded: end+1,
167
+ chunksTotal: response['chunksTotal'],
168
+ chunksUploaded: response['chunksUploaded']
169
+ });
170
+ }
171
171
}
172
172
173
173
return response;
0 commit comments