03-22-2017 06:50 AM
Hi,
I try to use angular-nuxeo to attach a blob, but I get excute exception.
Here is my code :
documentUploader(uid: string, file : File): IPromise<Object> {
let defer = this.$q.defer();
let options : any = {};
options.operationId = 'Blob.Attach';
options.client = this.nuxeo;
let myUploader : any;
myUploader = this.nuxeoClient.uploader.execute(options)
.params({
document: uid,
save : true,
xpath: "file:content"
});
myUploader.uploadFile(file)
.then((resp) => {
defer.resolve(resp);
},
(error) => {
defer.reject(error);
} );
return defer.promise;
}
How to instanciate the Uploader and then attached the blob?
Thanks for help
03-23-2017 05:28 AM
If you are in an Angular (1.x) application, you should register the client as an Angular service:
...
.service('nuxeo', function() {
return new Nuxeo({
baseURL: 'http://localhost:8080/nuxeo/',
auth: {
method: 'basic',
username: 'Administrator',
password: 'Administrator'
}
});
})
And then, you can inject nuxeo
in your controllers to use the client, such as other Angular services you may already use.
03-22-2017 06:59 AM
Hi,
First, you should use the last version of nuxeo-js-client that works within an Angular application, angular-nuxeo is not needed anymore. See the Angular Applications section.
Then, see the BatchUpload section, that contains a sample of exactly what you want to do "Attach an uploaded blob to a document".
03-22-2017 07:20 AM
Hi,
After done 'bower install nuxeo --save' , I tried to declare 'Nuxeo' as module in app.js but got error :
Error: [$injector:nomod] Module 'Nuxeo' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
I declared in index.html ==>
nuxeo/dist/nuxeo.js
Thanks for help
03-23-2017 03:50 AM
Hi Thomas,
In the readMe you say :
When added to your page, `Nuxeo` is available as a global variable.
var nuxeo = new Nuxeo({ ... });
What do you mean by added to your page , I don't see ? referencing it in app.js ? I saw that there is no angular.module in the new library.
Thanks for help
03-23-2017 05:28 AM
If you are in an Angular (1.x) application, you should register the client as an Angular service:
...
.service('nuxeo', function() {
return new Nuxeo({
baseURL: 'http://localhost:8080/nuxeo/',
auth: {
method: 'basic',
username: 'Administrator',
password: 'Administrator'
}
});
})
And then, you can inject nuxeo
in your controllers to use the client, such as other Angular services you may already use.
03-23-2017 05:34 AM
Hi,
I though that there was a module in the nuxeo js library, to declare in the main app.js and use it globaly in the angular app.
I go to follow your recommandation and create and simple .js service file and not a .ts file.
Thanks a lot for your quick reply
03-24-2017 05:23 AM
Hi Thomas, it works fine but I have a little problem.
When I want to fetch documents, the nuxeo server requires automation user/pwd even if I use client.connect() in my code : here is an example :
//Ici on liste tous les documents du WS DOEJ
function ListerLesDocumentsNuxeo() {
var defer = $q.defer();
//On force la connection ??
nuxeoClientConnect().then(function (resp) {
console.log('Connection ok ', resp.connected);
nuxeoClient.operation('Document.GetChildren')
.input(nuxeoPath)
.execute()
.then(function (docs) {
defer.resolve(docs);
}).catch(function (error) {
defer.reject(error);
throw error;
});
});
return defer.promise;
}
We use CAS on the nuxeo server so on client.connect(), we have this exception : Fetch API cannot load http://nuxeo.server/nuxeo/json/cmis. The request was redirected to 'https://cas.server/cas/login?service=http%3A%2F%2Fnuxeo.server%2Fnuxeo%2Fnxstartup.faces', which is disallowed for cross-origin requests that require preflight. Thanks for Help
03-24-2017 09:40 AM
You should deploy your Angular application on the Nuxeo Server, and put your application URL behind the Authentication filter so that the user will need to log in through CAS before accessing the app.
03-24-2017 09:45 AM
"put your application URL behind the Authentication filter", Can I have an example? Thanks
03-29-2017 04:00 AM
You could have a look at those projects https
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.