Skip to content

Commit

Permalink
Merge pull request #7296 from owncloud/access-token-upload-queue
Browse files Browse the repository at this point in the history
Fix access token renewal during upload
  • Loading branch information
kulmann authored Jul 19, 2022
2 parents a881823 + c55ef13 commit 475f664
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-token-renewal-during-upload
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Access token renewal during upload

We've fixed the access token renewal during ongoing uploads.

https://github.com/owncloud/web/issues/7240
https://github.com/owncloud/web/pull/7296
5 changes: 4 additions & 1 deletion packages/web-runtime/src/composables/upload/useUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export function useUpload(options: UploadOptions): UploadResult {

return {
isTusSupported,
headers: unref(headers),
onBeforeRequest: (req) => {
req.setHeader('Authorization', unref(headers).Authorization)
},
headers: () => unref(headers),
...(isTusSupported && {
tusMaxChunkSize: unref(tusMaxChunkSize),
tusHttpMethodOverride: unref(tusHttpMethodOverride),
Expand Down
18 changes: 12 additions & 6 deletions packages/web-runtime/src/services/uppyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ export class UppyService {
tusMaxChunkSize,
tusHttpMethodOverride,
tusExtension,
headers
onBeforeRequest
}: {
tusMaxChunkSize: number
tusHttpMethodOverride: boolean
tusExtension: string
headers: { [key: string]: string }
onBeforeRequest: () => void
}) {
const chunkSize = tusMaxChunkSize || Infinity
const uploadDataDuringCreation = tusExtension.includes('creation-with-upload')

const tusPluginOptions = {
headers: headers,
chunkSize: chunkSize,
removeFingerprintOnSuccess: true,
overridePatchMethod: !!tusHttpMethodOverride,
retryDelays: [0, 500, 1000],
// @TODO Use uploadDataDuringCreation once https://github.com/tus/tus-js-client/issues/397 is solved
uploadDataDuringCreation: false
uploadDataDuringCreation: false,
onBeforeRequest
}

const xhrPlugin = this.uppy.getPlugin('XHRUpload')
Expand All @@ -64,10 +64,16 @@ export class UppyService {
return
}

this.uppy.use(CustomTus, tusPluginOptions as TusOptions)
this.uppy.use(CustomTus, tusPluginOptions as unknown as TusOptions)
}

useXhr({ headers }: { headers: { [key: string]: string } }) {
useXhr({
headers
}: {
headers: () => {
[name: string]: string | number
}
}) {
const xhrPluginOptions: XHRUploadOptions = {
endpoint: '',
method: 'put',
Expand Down

0 comments on commit 475f664

Please sign in to comment.