Skip to content

Commit

Permalink
fix: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kukhariev committed Mar 2, 2020
1 parent 8d0e1cf commit df1158d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
12 changes: 2 additions & 10 deletions src/uploadx/lib/tus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ export class Tus extends Uploader {
'Upload-Length': `${this.size}`,
'Upload-Metadata': `${encodedMetaData}`
};
await this.request({
method: 'POST',
url: this.endpoint,
headers
});
await this.request({ method: 'POST', url: this.endpoint, headers });
const location = this.getValueFromResponse('location');
if (!location) {
throw new Error('Invalid or missing Location header');
Expand All @@ -34,11 +30,7 @@ export class Tus extends Uploader {
'Content-Type': 'application/offset+octet-stream',
'Upload-Offset': `${this.offset}`
};
await this.request({
method: 'PATCH',
body,
headers
});
await this.request({ method: 'PATCH', body, headers });
return this.getOffsetFromResponse();
}

Expand Down
3 changes: 2 additions & 1 deletion uploader-examples/tus-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export class TusExt extends Tus {
method: 'POST',
url: this.endpoint,
headers,
body
body,
progress: true
});
const location = this.getValueFromResponse('location');
if (!location) {
Expand Down
10 changes: 6 additions & 4 deletions uploader-examples/uploader-nginx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ export class NginxUploadModuleUploader extends Uploader {
method: 'POST',
body,
url: this.url,
headers
headers,
progress: true
});
return this.getOffsetFromResponse();
}

// abort not supported
abort() {}

private getOffsetFromResponse(): number {
if (this.responseStatus === 201) {
const [, end] = this.response
Expand All @@ -57,7 +62,4 @@ export class NginxUploadModuleUploader extends Uploader {
}
return this.offset;
}

// abort not supported
abort() {}
}

0 comments on commit df1158d

Please sign in to comment.