Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-upload-modify-time
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Upload modify time

We've included the `x-oc-mtime` header in upload requests to tell the backend the proper modify date of uploaded resources.

https://github.com/owncloud/web/pull/7630
https://github.com/owncloud/web/issues/7628
15 changes: 13 additions & 2 deletions packages/web-runtime/src/composables/upload/useUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useStore
} from 'web-pkg/src/composables'
import { computed, Ref, unref, watch } from '@vue/composition-api'
import { UppyService } from '../../services/uppyService'
import { UppyService, uppyHeaders } from '../../services/uppyService'
import * as uuid from 'uuid'

export interface UppyResource {
Expand Down Expand Up @@ -79,7 +79,18 @@ export function useUpload(options: UploadOptions): UploadResult {
onBeforeRequest: (req) => {
req.setHeader('Authorization', unref(headers).Authorization)
},
headers: () => unref(headers),
headers: (file) => {
const reqHeaders = {
'x-oc-mtime': file.data.lastModified / 1000,
...unref(headers)
} as uppyHeaders

if (unref(isTusSupported)) {
// Tus includes auth headers before each request
Comment thread
kulmann marked this conversation as resolved.
delete reqHeaders.Authorization
}
return reqHeaders
},
...(isTusSupported && {
tusMaxChunkSize: unref(tusMaxChunkSize),
tusHttpMethodOverride: unref(tusHttpMethodOverride),
Expand Down
17 changes: 9 additions & 8 deletions packages/web-runtime/src/services/uppyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ type UppyServiceTopics =
| 'drag-out'
| 'drop'

export type uppyHeaders = {
[name: string]: string | number
}

export class UppyService {
uppy: Uppy
uploadInputs: HTMLInputElement[] = []
Expand All @@ -36,17 +40,20 @@ export class UppyService {
tusMaxChunkSize,
tusHttpMethodOverride,
tusExtension,
onBeforeRequest
onBeforeRequest,
headers
}: {
tusMaxChunkSize: number
tusHttpMethodOverride: boolean
tusExtension: string
onBeforeRequest: () => void
headers: () => uppyHeaders
}) {
const chunkSize = tusMaxChunkSize || Infinity
const uploadDataDuringCreation = tusExtension.includes('creation-with-upload')

const tusPluginOptions = {
headers,
chunkSize: chunkSize,
removeFingerprintOnSuccess: true,
overridePatchMethod: !!tusHttpMethodOverride,
Expand All @@ -69,13 +76,7 @@ export class UppyService {
this.uppy.use(CustomTus, tusPluginOptions as unknown as TusOptions)
}

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