mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Downloads from Clara.io and uploads to asset server
This commit is contained in:
parent
615627e981
commit
a94a304700
4 changed files with 31 additions and 61 deletions
|
@ -320,6 +320,7 @@ ScrollingWindow {
|
||||||
id: timer
|
id: timer
|
||||||
}
|
}
|
||||||
function uploadClicked(fileUrl) {
|
function uploadClicked(fileUrl) {
|
||||||
|
console.log("Upload clicked url: " + fileUrl);
|
||||||
if (uploadOpen) {
|
if (uploadOpen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1543,7 +1543,10 @@ void Application::initializeUi() {
|
||||||
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
|
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
|
||||||
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
||||||
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
||||||
rootContext->setContextProperty("File", new FileScriptingInterface(engine));
|
//rootContext->setContextProperty("File", new FileScriptingInterface(engine));
|
||||||
|
FileScriptingInterface* fileDownload = new FileScriptingInterface(engine);
|
||||||
|
rootContext->setContextProperty("File", fileDownload);
|
||||||
|
connect(fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::toggleAssetServerWidget);
|
||||||
rootContext->setContextProperty("MyAvatar", getMyAvatar());
|
rootContext->setContextProperty("MyAvatar", getMyAvatar());
|
||||||
rootContext->setContextProperty("Messages", DependencyManager::get<MessagesClient>().data());
|
rootContext->setContextProperty("Messages", DependencyManager::get<MessagesClient>().data());
|
||||||
rootContext->setContextProperty("Recording", DependencyManager::get<RecordingScriptingInterface>().data());
|
rootContext->setContextProperty("Recording", DependencyManager::get<RecordingScriptingInterface>().data());
|
||||||
|
@ -5035,6 +5038,7 @@ void Application::toggleAssetServerWidget(QString filePath) {
|
||||||
|
|
||||||
auto startUpload = [=](QQmlContext* context, QObject* newObject){
|
auto startUpload = [=](QQmlContext* context, QObject* newObject){
|
||||||
if (!filePath.isEmpty()) {
|
if (!filePath.isEmpty()) {
|
||||||
|
qDebug() << "file in toggle: " + filePath;
|
||||||
emit uploadRequest(filePath);
|
emit uploadRequest(filePath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,16 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent
|
||||||
void FileScriptingInterface::runUnzip(QString path, QUrl url) {
|
void FileScriptingInterface::runUnzip(QString path, QUrl url) {
|
||||||
qDebug() << "Url that was downloaded: " + url.toString();
|
qDebug() << "Url that was downloaded: " + url.toString();
|
||||||
qDebug() << "Path where download is saved: " + path;
|
qDebug() << "Path where download is saved: " + path;
|
||||||
unzipFile(path);
|
QString file = unzipFile(path);
|
||||||
|
if (file != "") {
|
||||||
|
qDebug() << "file to upload: " + file;
|
||||||
|
QUrl url = QUrl::fromLocalFile(file);
|
||||||
|
qDebug() << "url from local file: " + url.toString();
|
||||||
|
emit unzipSuccess(url.toString());
|
||||||
|
//Application::toggleAssetServerWidget(file);
|
||||||
|
} else {
|
||||||
|
qDebug() << "unzip failed";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileScriptingInterface::testUrl(QUrl url) {
|
bool FileScriptingInterface::testUrl(QUrl url) {
|
||||||
|
@ -68,67 +77,22 @@ void FileScriptingInterface::downloadZip(QString path, const QString link) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// clement's help :D
|
// clement's help :D
|
||||||
void FileScriptingInterface::unzipFile(QString path) {
|
QString FileScriptingInterface::unzipFile(QString path) {
|
||||||
//ResourceRequest* request = qobject_cast<ResourceRequest*>(sender());
|
|
||||||
//QUrl url = request->getUrl();
|
|
||||||
|
|
||||||
//if (request->getResult() == ResourceRequest::Success) {
|
qDebug() << "Zip file was downloaded";
|
||||||
qDebug() << "Zip file was downloaded";
|
QDir dir(path);
|
||||||
QDir dir(path);
|
QString dirName = dir.path();
|
||||||
//QByteArray compressedFileContent = request->getData(); // <-- Downloaded file is in here
|
qDebug() << "Zip directory is stored at: " + dirName;
|
||||||
//QBuffer buffer(&compressedFileContent);
|
QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test");
|
||||||
//buffer.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
//QString zipFileName = QFile::decodeName(compressedFileContent);
|
qDebug() << list;
|
||||||
QString dirName = dir.path();
|
|
||||||
//QDir testPath("C:/Users/elisa/Downloads/banana.zip");
|
|
||||||
qDebug() << "Zip directory is stored at: " + dirName;
|
|
||||||
QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test");
|
|
||||||
|
|
||||||
qDebug() << list;
|
if (!list.isEmpty()) {
|
||||||
|
return list.front();
|
||||||
//QFileInfoList files = dir.entryInfoList();
|
} else {
|
||||||
QFileInfoList files = dir.entryInfoList();
|
qDebug() << "Extraction failed";
|
||||||
foreach(QFileInfo file, files) {
|
return "";
|
||||||
qDebug() << "My file: " + file.fileName();
|
}
|
||||||
recursiveFileScan(file, &dirName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*foreach (QFileInfo file, files) {
|
|
||||||
if (file.isDir()) {
|
|
||||||
if (file.fileName().contains(".zip")) {
|
|
||||||
qDebug() << "Zip file expanded: " + file.fileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Regular file logged: " + file.fileName();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//QFile file =
|
|
||||||
//need to convert this byte array to a file
|
|
||||||
/*QuaZip zip(zipFileName);
|
|
||||||
|
|
||||||
if (zip.open(QuaZip::mdUnzip)) {
|
|
||||||
qDebug() << "Opened";
|
|
||||||
|
|
||||||
for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) {
|
|
||||||
// do something
|
|
||||||
qDebug() << zip.getCurrentFileName();
|
|
||||||
}
|
|
||||||
if (zip.getZipError() == UNZ_OK) {
|
|
||||||
// ok, there was no error
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
//buffer.close();
|
|
||||||
//} else {
|
|
||||||
// qDebug() << "Could not download the zip file";
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,11 @@ public slots:
|
||||||
void runUnzip(QString path, QUrl url);
|
void runUnzip(QString path, QUrl url);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void unzipSuccess(QString url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//void downloadZip();
|
//void downloadZip();
|
||||||
void unzipFile(QString path);
|
QString unzipFile(QString path);
|
||||||
void recursiveFileScan(QFileInfo file, QString* dirName);
|
void recursiveFileScan(QFileInfo file, QString* dirName);
|
||||||
void downloadZip(QString path, const QString link);
|
void downloadZip(QString path, const QString link);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue