diff --git a/app/builders/messages/message_builder.rb b/app/builders/messages/message_builder.rb
index f84e38ca7..2df286f4a 100644
--- a/app/builders/messages/message_builder.rb
+++ b/app/builders/messages/message_builder.rb
@@ -31,7 +31,6 @@ class Messages::MessageBuilder
@attachments.each do |uploaded_attachment|
@message.attachments.build(
account_id: @message.account_id,
- file_type: file_type(uploaded_attachment&.content_type),
file: uploaded_attachment
)
end
diff --git a/app/controllers/api/v1/widget/messages_controller.rb b/app/controllers/api/v1/widget/messages_controller.rb
index 0d9ab6323..a35506d96 100644
--- a/app/controllers/api/v1/widget/messages_controller.rb
+++ b/app/controllers/api/v1/widget/messages_controller.rb
@@ -31,7 +31,6 @@ class Api::V1::Widget::MessagesController < Api::V1::Widget::BaseController
params[:message][:attachments].each do |uploaded_attachment|
@message.attachments.new(
account_id: @message.account_id,
- file_type: helpers.file_type(uploaded_attachment&.content_type),
file: uploaded_attachment
)
end
diff --git a/app/javascript/dashboard/api/inbox/message.js b/app/javascript/dashboard/api/inbox/message.js
index 22f417052..f3c5e83e9 100644
--- a/app/javascript/dashboard/api/inbox/message.js
+++ b/app/javascript/dashboard/api/inbox/message.js
@@ -14,12 +14,12 @@ export const buildCreatePayload = ({
let payload;
if (files && files.length !== 0) {
payload = new FormData();
- files.forEach(file => {
- payload.append('attachments[]', file, file.name);
- });
if (message) {
payload.append('content', message);
}
+ files.forEach(file => {
+ payload.append('attachments[]', file);
+ });
payload.append('private', isPrivate);
payload.append('echo_id', echoId);
payload.append('cc_emails', ccEmails);
diff --git a/app/javascript/dashboard/components/widgets/AttachmentsPreview.vue b/app/javascript/dashboard/components/widgets/AttachmentsPreview.vue
index d484cbb4f..57797b5f3 100644
--- a/app/javascript/dashboard/components/widgets/AttachmentsPreview.vue
+++ b/app/javascript/dashboard/components/widgets/AttachmentsPreview.vue
@@ -7,7 +7,7 @@
>
@@ -15,12 +15,12 @@
- {{ attachment.resource.name }}
+ {{ attachment.resource.filename }}
- {{ formatFileSize(attachment.resource.size) }}
+ {{ formatFileSize(attachment.resource.byte_size) }}
diff --git a/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue b/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue
index 0a9ee3629..f53cfcfc5 100644
--- a/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue
+++ b/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue
@@ -19,7 +19,8 @@
:multiple="enableMultipleFileUpload"
:drop="true"
:drop-directory="false"
- @input-file="onFileUpload"
+ :data="{ direct_upload_url: '/rails/active_storage/direct_uploads', direct_upload: true }"
+ @input-file="onDirectFileUpload"
>
import FileUpload from 'vue-upload-component';
+import * as ActiveStorage from "activestorage";
import {
hasPressedAltAndWKey,
hasPressedAltAndAKey,
@@ -109,7 +111,7 @@ export default {
type: Boolean,
default: false,
},
- onFileUpload: {
+ onDirectFileUpload: {
type: Function,
default: () => {},
},
@@ -150,6 +152,9 @@ export default {
default: true,
},
},
+ mounted() {
+ ActiveStorage.start();
+ },
computed: {
isNote() {
return this.mode === REPLY_EDITOR_MODES.NOTE;
diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue
index d7385a3fd..03019f55e 100644
--- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue
+++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue
@@ -61,7 +61,7 @@
{
+ if (error) {
+ this.showAlert(
+ error
+ );
+ } else {
+ this.attachedFiles.push({
+ currentChatId: this.currentChat.id,
+ resource: blob,
+ isPrivate: this.isPrivate,
+ thumb: null,
+ blobSignedId: blob.signed_id,
+ });
+ }
+ });
+ } else {
+ this.showAlert(
+ this.$t('CONVERSATION.FILE_SIZE_LIMIT', {
+ MAXIMUM_FILE_UPLOAD_SIZE,
+ })
+ );
+ }
+ },
onFileUpload(file) {
if (!file) {
return;
@@ -486,7 +516,7 @@ export default {
if (this.attachedFiles && this.attachedFiles.length) {
messagePayload.files = [];
this.attachedFiles.forEach(attachment => {
- messagePayload.files.push(attachment.resource.file);
+ messagePayload.files.push(attachment.blobSignedId);
});
}
diff --git a/app/javascript/widget/api/endPoints.js b/app/javascript/widget/api/endPoints.js
index fddcfa3d6..12073c872 100755
--- a/app/javascript/widget/api/endPoints.js
+++ b/app/javascript/widget/api/endPoints.js
@@ -41,7 +41,7 @@ const sendAttachment = ({ attachment }) => {
const { file } = attachment;
const formData = new FormData();
- formData.append('message[attachments][]', file, file.name);
+ formData.append('message[attachments][]', file);
formData.append('message[referer_url]', referrerURL);
formData.append('message[timestamp]', timestamp);
return {
diff --git a/app/javascript/widget/components/ChatAttachment.vue b/app/javascript/widget/components/ChatAttachment.vue
index 501c1bcb2..e1f5b6af3 100755
--- a/app/javascript/widget/components/ChatAttachment.vue
+++ b/app/javascript/widget/components/ChatAttachment.vue
@@ -2,7 +2,8 @@