mirror of https://github.com/apache/lucene.git
SOLR-7782 Allow non-JSON and JSON array uploads
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1690535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2cc7d08819
commit
d821ea9fd2
|
@ -85,35 +85,43 @@ solrAdminApp.controller('DocumentsController',
|
||||||
|
|
||||||
if ($scope.type == "json" || $scope.type == "wizard") {
|
if ($scope.type == "json" || $scope.type == "wizard") {
|
||||||
postData = "[" + $scope.document + "]";
|
postData = "[" + $scope.document + "]";
|
||||||
contentType = "application/json";
|
contentType = "json";
|
||||||
} else if ($scope.type == "csv") {
|
} else if ($scope.type == "csv") {
|
||||||
postData = $scope.document;
|
postData = $scope.document;
|
||||||
contentType = "application/csv";
|
contentType = "csv";
|
||||||
} else if ($scope.type == "xml") {
|
} else if ($scope.type == "xml") {
|
||||||
postData = "<add>" + $scope.document + "</add>";
|
postData = "<add>" + $scope.document + "</add>";
|
||||||
contentType = "text/xml";
|
contentType = "xml";
|
||||||
} else if ($scope.type == "upload") {
|
} else if ($scope.type == "upload") {
|
||||||
doingFileUpload = true;
|
doingFileUpload = true;
|
||||||
params.raw = $scope.literalParams;
|
params.raw = $scope.literalParams;
|
||||||
} else if ($scope.type == "solr") {
|
} else if ($scope.type == "solr") {
|
||||||
postData = $scope.document;
|
postData = $scope.document;
|
||||||
if (postData[0] == "<") {
|
if (postData[0] == "<") {
|
||||||
contentType = "text/xml";
|
contentType = "xml";
|
||||||
} else if (postData[0] == "{") {
|
} else if (postData[0] == "{" || postData[0] == '[') {
|
||||||
contentType = "application/json";
|
contentType = "json";
|
||||||
} else {
|
} else {
|
||||||
alert("Cannot identify content type")
|
alert("Cannot identify content type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!doingFileUpload) {
|
if (!doingFileUpload) {
|
||||||
Update.post(params, postData).then(function (success) {
|
var callback = function (success) {
|
||||||
$scope.responseStatus = "success";
|
$scope.responseStatus = "success";
|
||||||
delete success.$promise;
|
delete success.$promise;
|
||||||
delete success.$resolved;
|
delete success.$resolved;
|
||||||
$scope.response = JSON.stringify(success, null, ' ');
|
$scope.response = JSON.stringify(success, null, ' ');
|
||||||
}).fail(function (failure) {
|
};
|
||||||
|
var failure = function (failure) {
|
||||||
$scope.responseStatus = failure;
|
$scope.responseStatus = failure;
|
||||||
});
|
};
|
||||||
|
if (contentType == "json") {
|
||||||
|
Update.postJson(params, postData, callack, failure);
|
||||||
|
} else if (contentType == "xml") {
|
||||||
|
Update.postXml(params, postData, callback, failure);
|
||||||
|
} else if (contentType == "csv") {
|
||||||
|
Update.postCsv(params, postData, callback, failure);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var file = $scope.fileUpload;
|
var file = $scope.fileUpload;
|
||||||
console.log('file is ' + JSON.stringify(file));
|
console.log('file is ' + JSON.stringify(file));
|
||||||
|
|
|
@ -78,10 +78,13 @@ solrAdminServices.factory('System',
|
||||||
}])
|
}])
|
||||||
.factory('Update',
|
.factory('Update',
|
||||||
['$resource', function($resource) {
|
['$resource', function($resource) {
|
||||||
return $resource('/solr/:core/:handler', {core: '@core', wt:'json', _:Date.now(), handler:'/update'}, {
|
return $resource('/solr/:core/:handler', {core: '@core', wt:'json', _:Date.now(), handler:'update'}, {
|
||||||
"optimize": {params: { optimize: "true"}},
|
"optimize": {params: { optimize: "true"}},
|
||||||
"commit": {params: {commit: "true"}},
|
"commit": {params: {commit: "true"}},
|
||||||
"post": {method: "POST", params: {handler: '@handler'}}
|
"post": {headers: {'Content-type': 'application/json'}, method: "POST", params: {handler: '@handler'}},
|
||||||
|
"postJson": {headers: {'Content-type': 'application/json'}, method: "POST", params: {handler: '@handler'}},
|
||||||
|
"postXml": {headers: {'Content-type': 'text/xml'}, method: "POST", params: {handler: '@handler'}},
|
||||||
|
"postCsv": {headers: {'Content-type': 'application/csv'}, method: "POST", params: {handler: '@handler'}}
|
||||||
});
|
});
|
||||||
}])
|
}])
|
||||||
.service('FileUpload', function ($http) {
|
.service('FileUpload', function ($http) {
|
||||||
|
|
Loading…
Reference in New Issue