MCPcopy Create free account
hub / github.com/audacity/audacity / GetUploadRequestPayload

Function GetUploadRequestPayload

libraries/lib-cloud-audiocom/UploadService.cpp:57–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57std::string GetUploadRequestPayload(
58 const wxString& filePath, const wxString& projectName, bool isPublic)
59{
60 rapidjson::Document document;
61 document.SetObject();
62
63 const wxFileName fileName(filePath);
64 const auto mimeType = DeduceMimeType(fileName.GetExt());
65
66 document.AddMember(
67 "mime",
68 rapidjson::Value(
69 mimeType.data(), mimeType.length(), document.GetAllocator()),
70 document.GetAllocator());
71
72 const auto downloadMime = GetServiceConfig().GetDownloadMime();
73
74 if (!downloadMime.empty())
75 {
76 document.AddMember(
77 "download_mime",
78 rapidjson::Value(
79 downloadMime.data(), downloadMime.length(),
80 document.GetAllocator()),
81 document.GetAllocator());
82 }
83
84 const auto name = audacity::ToUTF8(projectName.empty() ? fileName.GetFullName() : projectName);
85
86 document.AddMember(
87 "name",
88 rapidjson::Value(name.data(), name.length(), document.GetAllocator()),
89 document.GetAllocator());
90
91 document.AddMember(
92 "size",
93 rapidjson::Value(static_cast<int64_t>(fileName.GetSize().GetValue())),
94 document.GetAllocator());
95
96 document.AddMember(
97 "public", rapidjson::Value(isPublic), document.GetAllocator());
98
99 document.AddMember(
100 "method", rapidjson::Value("PUT"), document.GetAllocator());
101
102 rapidjson::StringBuffer buffer;
103 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
104 document.Accept(writer);
105
106 return std::string(buffer.GetString());
107}
108
109std::string GetProgressPayload(uint64_t current, uint64_t total)
110{

Callers 1

InitiateUploadMethod · 0.85

Calls 10

DeduceMimeTypeFunction · 0.85
ToUTF8Function · 0.85
GetDownloadMimeMethod · 0.80
GetFullNameMethod · 0.80
dataMethod · 0.45
lengthMethod · 0.45
emptyMethod · 0.45
GetValueMethod · 0.45
GetSizeMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected