mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Add a new constructor for FileAttachment to support precomputation of mime type and attachment type.
PiperOrigin-RevId: 672643121
This commit is contained in:
committed by
Copybara-Service
parent
48001e65cd
commit
5a1bfcb904
@@ -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)) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user