History

Upload QByteArray

EdgarPironti committed 10 years ago

Commit 1db6d0e1 parent 1b18d362 files · +8 −16Browse files

Showing the changes to libraries/script-engine/src/RecordingScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

libraries/script-engine/src/RecordingScriptingInterface.cpp+8−13
@@ -177,8 +177,7 @@ void RecordingScriptingInterface::saveRecording(const QString& filename) { · 176 unmodified lines
177}177}
178 178
179bool RecordingScriptingInterface::saveRecordingToAsset(QScriptValue getClipAtpUrl) {179bool RecordingScriptingInterface::saveRecordingToAsset(QScriptValue getClipAtpUrl) {
180 180 if (!getClipAtpUrl.isFunction())
181 if (!getClipAtpUrl.isFunction())
182 return false;181 return false;
183 182
184 if (QThread::currentThread() != thread()) {183 if (QThread::currentThread() != thread()) {
@@ -192,13 +191,14 @@ bool RecordingScriptingInterface::saveRecordingToAsset(QScriptValue getClipAtpUr · 7 unmodified lines
192 return false;191 return false;
193 }192 }
194 193
195 QString filename = "./temp.hfr";194 //QString filename = "./temp.hfr";
196 recording::Clip::toFile(filename, _lastClip);195 //recording::Clip::toFile(filename, _lastClip);
197
198 QUrl url{ filename };
199 196
200 if (auto upload = DependencyManager::get<AssetClient>()->createUpload(url.toLocalFile())) { // Here we should use the other implementation of createUpload, but we need the QByteArray of the _lastClip197 //QUrl url{ filename };
201 198
199 //if (auto upload = DependencyManager::get<AssetClient>()->createUpload(url.toLocalFile())) {
200
201 if (auto upload = DependencyManager::get<AssetClient>()->createUpload(recording::Clip::toBuffer(_lastClip), HFR_EXTENSION)) {
202 QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {202 QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
203 auto filename = QFileInfo(upload->getFilename()).fileName();203 auto filename = QFileInfo(upload->getFilename()).fileName();
204 QString clip_atp_url = "";204 QString clip_atp_url = "";
@@ -215,18 +215,13 @@ bool RecordingScriptingInterface::saveRecordingToAsset(QScriptValue getClipAtpUr · 10 unmodified lines
215 args << clip_atp_url;215 args << clip_atp_url;
216 getClipAtpUrl.call(QScriptValue(), args);216 getClipAtpUrl.call(QScriptValue(), args);
217 });217 });
218
219 // start the upload now
220 upload->start();218 upload->start();
221 return true;219 return true;
222 220 }
223 }
224 221
225 return false;222 return false;
226
227}223}
228 224
229
230void RecordingScriptingInterface::loadLastRecording() {225void RecordingScriptingInterface::loadLastRecording() {
231 if (QThread::currentThread() != thread()) {226 if (QThread::currentThread() != thread()) {
232 QMetaObject::invokeMethod(this, "loadLastRecording", Qt::BlockingQueuedConnection);227 QMetaObject::invokeMethod(this, "loadLastRecording", Qt::BlockingQueuedConnection);