@@ -128,14 +128,12 @@ export class {{ service.name | caseUcfirst }} extends Service {
128
128
headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
129
129
}
130
130
131
- console.log(headers['content-range']);
132
-
133
131
let uploadableChunkTrimmed: Uint8Array;
134
132
135
- if(currentPosition >= Client.CHUNK_SIZE) {
133
+ if(currentPosition + 1 >= Client.CHUNK_SIZE) {
136
134
uploadableChunkTrimmed = uploadableChunk;
137
135
} else {
138
- uploadableChunkTrimmed = new Uint8Array(currentPosition);
136
+ uploadableChunkTrimmed = new Uint8Array(currentPosition + 1 );
139
137
for(let i = 0; i < = currentPosition; i++) {
140
138
uploadableChunkTrimmed[i] = uploadableChunk[i];
141
139
}
@@ -145,7 +143,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
145
143
headers['x-{{spec .title | caseLower }}-id'] = id;
146
144
}
147
145
148
- payload['{{ parameter .name }}'] = new File([uploadableChunkTrimmed], {{ parameter .name | caseCamel | escapeKeyword }}.name);
146
+ payload['{{ parameter .name }}'] = { type: 'file', file: new File([uploadableChunkTrimmed], {{ parameter .name | caseCamel | escapeKeyword }}.name), filename: {{ parameter . name | caseCamel | escapeKeyword }}.name } ;
149
147
150
148
response = await this.client.call('{{ method .method | caseLower }}', path, headers, payload{% if method .type == ' location' %}, 'arraybuffer'{% endif %});
151
149
@@ -172,12 +170,14 @@ export class {{ service.name | caseUcfirst }} extends Service {
172
170
let i = 0;
173
171
for(const b of chunk) {
174
172
uploadableChunk[currentPosition] = chunk[i];
175
- i++;
176
- currentPosition++;
177
173
178
- if(currentPosition >= Client.CHUNK_SIZE) {
174
+ if(currentPosition + 1 >= Client.CHUNK_SIZE) {
179
175
await uploadChunk();
176
+ currentPosition--;
180
177
}
178
+
179
+ i++;
180
+ currentPosition++;
181
181
}
182
182
}
183
183
0 commit comments