Skip to content

Commit 5127539

Browse files
committed
(fix) file type/extension
1 parent f001513 commit 5127539

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ messageActionHandler({ roomId, action, message }) {
619619

620620
(5) `textarea-action-handler` can be used to add an extra icon on the right of the textarea, and recieve an event when clicking it.
621621

622-
(6) All file params contain: `{ blob, localURL, name, size, type }`
622+
(6) All file params contain: `{ blob, localURL, name, size, type, extension }`
623623

624624
(7) `replyMessage` object is available when the user replied to another message by clicking the corresponding icon, and contains the message information that was clicked.
625625

demo/src/ChatContainer.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ export default {
423423
name: file.name,
424424
size: file.size,
425425
type: file.type,
426+
extension: file.extension,
426427
url: file.localUrl
427428
}
428429
if (file.audio) {
@@ -463,6 +464,7 @@ export default {
463464
name: file.name,
464465
size: file.size,
465466
type: file.type,
467+
extension: file.extension,
466468
url: file.url || file.localUrl
467469
}
468470
if (file.audio) {
@@ -490,7 +492,7 @@ export default {
490492
const uploadFileRef = filesRef
491493
.child(this.currentUserId)
492494
.child(messageId)
493-
.child(`${file.name}.${file.type}`)
495+
.child(`${file.name}.${file.extension || file.type}`)
494496
495497
await uploadFileRef.put(file.blob, { contentType: file.type })
496498
const url = await uploadFileRef.getDownloadURL()

src/ChatWindow/Room.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,8 @@ export default {
767767
blob: blobFile,
768768
name: file.name.substring(0, typeIndex),
769769
size: file.size,
770-
type: file.name.substring(typeIndex + 1) || file.type,
770+
type: file.type,
771+
extension: file.name.substring(typeIndex + 1),
771772
localUrl: fileURL
772773
}
773774
if (this.isImageCheck(this.file)) this.imageFile = fileURL

0 commit comments

Comments
 (0)