| 55 | } |
| 56 | |
| 57 | std::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 | |
| 109 | std::string GetProgressPayload(uint64_t current, uint64_t total) |
| 110 | { |
no test coverage detected