void ATPAssetMigrator::migrateResource(ResourceRequest* request) { // use an asset client to upload the asset auto assetClient = DependencyManager::get<AssetClient>(); QFileInfo assetInfo { request->getUrl().fileName() }; auto upload = assetClient->createUpload(request->getData(), assetInfo.completeSuffix()); if (upload) { // add this URL to our hash of AssetUpload to original URL _originalURLs.insert(upload, request->getUrl()); qCDebug(asset_migrator) << "Starting upload of asset from" << request->getUrl(); // connect to the finished signal so we know when the AssetUpload is done QObject::connect(upload, &AssetUpload::finished, this, &ATPAssetMigrator::assetUploadFinished); // start the upload now upload->start(); } else { // show a QMessageBox to say that there is no local asset server QString messageBoxText = QString("Could not upload \n\n%1\n\nbecause you are currently not connected" \ " to a local asset-server.").arg(assetInfo.fileName()); QMessageBox::information(_dialogParent, "Failed to Upload", messageBoxText); } }
void AssetUploadDialogFactory::showDialog() { auto nodeList = DependencyManager::get<NodeList>(); if (nodeList->getThisNodeCanRez()) { auto filename = QFileDialog::getOpenFileName(_dialogParent, "Select a file to upload"); if (!filename.isEmpty()) { qDebug() << "Selected filename for upload to asset-server: " << filename; auto assetClient = DependencyManager::get<AssetClient>(); auto upload = assetClient->createUpload(filename); if (upload) { // connect to the finished signal so we know when the AssetUpload is done QObject::connect(upload, &AssetUpload::finished, this, &AssetUploadDialogFactory::handleUploadFinished); // start the upload now upload->start(); } else { // show a QMessageBox to say that there is no local asset server QString messageBoxText = QString("Could not upload \n\n%1\n\nbecause you are currently not connected" \ " to a local asset-server.").arg(QFileInfo(filename).fileName()); QMessageBox::information(_dialogParent, "Failed to Upload", messageBoxText); } } } else { // we don't have permission to upload to asset server in this domain - show the permission denied error showErrorDialog(QString(), PERMISSION_DENIED_ERROR); } }
void ProcessListView::dropEvent(QDropEvent *_event) { if(_event->mimeData()->hasFormat("text/uri-list")) { if(_event->mimeData()->hasUrls()) { if(!((QDir)_event->mimeData()->urls().at(0).toLocalFile()).exists()) { qDebug() << "ProcessListView: dropEvent: " << _event->mimeData()->urls().at(0).toLocalFile(); emit createUpload(_event->mimeData()->urls().at(0).toLocalFile()); } bool isInternetUrl = _event->mimeData()->urls().at(0).toString().contains(QRegExp("^http://*", Qt::CaseSensitive, QRegExp::RegExp2)); if(isInternetUrl) { qDebug() << "ProcessListView: dropEvent: Internet Url "<< _event->mimeData()->urls().at(0).toString().left(45) << " --> " << isInternetUrl; emit createDownload(_event->mimeData()->urls().at(0).toString()); } } } }