client side fixes for upload with no extension

This commit is contained in:
Stephen Birarda 2016-03-08 12:18:39 -08:00
parent 1ece9aac26
commit 8fa32e75b2
4 changed files with 17 additions and 11 deletions

View file

@ -421,14 +421,20 @@ void AssetServer::loadMappingsFromFile() {
QFile mapFile { mapFilePath }; QFile mapFile { mapFilePath };
if (mapFile.exists()) { if (mapFile.exists()) {
if (mapFile.open(QIODevice::ReadOnly)) { if (mapFile.open(QIODevice::ReadOnly)) {
auto jsonDocument = QJsonDocument::fromJson(mapFile.readAll()); QJsonParseError error;
_fileMappings = jsonDocument.object().toVariantHash();
qInfo() << "Loaded" << _fileMappings.count() << "mappings from map file at" << mapFilePath; auto jsonDocument = QJsonDocument::fromJson(mapFile.readAll(), &error);
} else {
qCritical() << "Failed to read mapping file at" << mapFilePath << "- assignment with not continue."; if (error.error == QJsonParseError::NoError) {
setFinished(true); _fileMappings = jsonDocument.object().toVariantHash();
qInfo() << "Loaded" << _fileMappings.count() << "mappings from map file at" << mapFilePath;
return;
}
} }
qCritical() << "Failed to read mapping file at" << mapFilePath << "- assignment with not continue.";
setFinished(true);
} else { } else {
qInfo() << "No existing mappings loaded from file since no file was found at" << mapFilePath; qInfo() << "No existing mappings loaded from file since no file was found at" << mapFilePath;
} }

View file

@ -4334,14 +4334,14 @@ void Application::modelUploadFinished(AssetUpload* upload, const QString& hash)
auto filename = QFileInfo(upload->getFilename()).fileName(); auto filename = QFileInfo(upload->getFilename()).fileName();
if ((upload->getError() == AssetUpload::NoError) && if ((upload->getError() == AssetUpload::NoError) &&
(FBX_EXTENSION.endsWith(upload->getExtension(), Qt::CaseInsensitive) || (filename.endsWith(FBX_EXTENSION, Qt::CaseInsensitive) ||
OBJ_EXTENSION.endsWith(upload->getExtension(), Qt::CaseInsensitive))) { filename.endsWith(OBJ_EXTENSION, Qt::CaseInsensitive))) {
auto entities = DependencyManager::get<EntityScriptingInterface>(); auto entities = DependencyManager::get<EntityScriptingInterface>();
EntityItemProperties properties; EntityItemProperties properties;
properties.setType(EntityTypes::Model); properties.setType(EntityTypes::Model);
properties.setModelURL(QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension())); properties.setModelURL(QString("%1:%2").arg(URL_SCHEME_ATP).arg(hash);
properties.setPosition(_myCamera.getPosition() + _myCamera.getOrientation() * Vectors::FRONT * 2.0f); properties.setPosition(_myCamera.getPosition() + _myCamera.getOrientation() * Vectors::FRONT * 2.0f);
properties.setName(QUrl(upload->getFilename()).fileName()); properties.setName(QUrl(upload->getFilename()).fileName());

View file

@ -142,7 +142,7 @@ void ATPAssetMigrator::migrateResource(ResourceRequest* request) {
QFileInfo assetInfo { request->getUrl().fileName() }; QFileInfo assetInfo { request->getUrl().fileName() };
auto upload = assetClient->createUpload(request->getData(), assetInfo.completeSuffix()); auto upload = assetClient->createUpload(request->getData());
if (upload) { if (upload) {
// add this URL to our hash of AssetUpload to original URL // add this URL to our hash of AssetUpload to original URL

View file

@ -87,7 +87,7 @@ void AssetUploadDialogFactory::handleUploadFinished(AssetUpload* upload, const Q
// setup the line edit to hold the copiable text // setup the line edit to hold the copiable text
QLineEdit* lineEdit = new QLineEdit; QLineEdit* lineEdit = new QLineEdit;
QString atpURL = QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension()); QString atpURL = QString("%1:%2").arg(URL_SCHEME_ATP).arg(hash);
// set the ATP URL as the text value so it's copiable // set the ATP URL as the text value so it's copiable
lineEdit->insert(atpURL); lineEdit->insert(atpURL);