@@ -531,7 +531,7 @@ export class Uploader {
531531 } ,
532532 headers : {
533533 ...this . _customHeaders ,
534- 'X-OC-Mtime' : Math . floor ( file . lastModified / 1000 ) ,
534+ ... this . _mtimeHeader ( file ) ,
535535 'OC-Total-Length' : file . size ,
536536 'Content-Type' : 'application/octet-stream' ,
537537 } ,
@@ -579,7 +579,7 @@ export class Uploader {
579579 url : `${ tempUrl } /.file` ,
580580 headers : {
581581 ...this . _customHeaders ,
582- 'X-OC-Mtime' : Math . floor ( file . lastModified / 1000 ) ,
582+ ... this . _mtimeHeader ( file ) ,
583583 'OC-Total-Length' : file . size ,
584584 Destination : encodedDestinationFile ,
585585 } ,
@@ -633,7 +633,7 @@ export class Uploader {
633633 } ,
634634 headers : {
635635 ...this . _customHeaders ,
636- 'X-OC-Mtime' : Math . floor ( file . lastModified / 1000 ) ,
636+ ... this . _mtimeHeader ( file ) ,
637637 'Content-Type' : file . type ,
638638 } ,
639639 } ,
@@ -685,4 +685,19 @@ export class Uploader {
685685 return promise
686686 }
687687
688+ /**
689+ * Create modification time headers if valid value is available.
690+ * It can be invalid on Android devices if SD cards with NTFS / FAT are used,
691+ * as those files might use the NT epoch for time so the value will be negative.
692+ *
693+ * @param file The file to upload
694+ */
695+ private _mtimeHeader ( file : File ) : { 'X-OC-Mtime' ?: number } {
696+ const mtime = Math . floor ( file . lastModified / 1000 )
697+ if ( mtime > 0 ) {
698+ return { 'X-OC-Mtime' : mtime }
699+ }
700+ return { }
701+ }
702+
688703}
0 commit comments