diff --git a/sharing/file_attachment.cc b/sharing/file_attachment.cc index 7ec995f7..3917e76e 100644 --- a/sharing/file_attachment.cc +++ b/sharing/file_attachment.cc @@ -56,10 +56,11 @@ std::string MimeTypeFromPath(const std::filesystem::path& path) { } // namespace FileAttachment::FileAttachment(std::filesystem::path file_path, + absl::string_view mime_type, std::string parent_folder, int32_t batch_id, SourceType source_type) : Attachment(Attachment::Family::kFile, /*size=*/0, batch_id, source_type), - mime_type_(MimeTypeFromPath(file_path)), + mime_type_(mime_type.empty() ? MimeTypeFromPath(file_path) : mime_type), type_(FileAttachmentTypeFromMimeType(mime_type_)), file_path_(std::move(file_path)), parent_folder_(std::move(parent_folder)) { diff --git a/sharing/file_attachment.h b/sharing/file_attachment.h index 9bc1e28e..b156b23d 100644 --- a/sharing/file_attachment.h +++ b/sharing/file_attachment.h @@ -36,6 +36,7 @@ class FileAttachment : public Attachment { using Type = nearby::sharing::service::proto::FileMetadata::Type; explicit FileAttachment(std::filesystem::path file_path, + absl::string_view mime_type = "", std::string parent_folder = "", int32_t batch_id = 0, SourceType source_type = SourceType::kUnknown); FileAttachment(int64_t id, int64_t size, std::string file_name,