upload files

I am uploading some files in a tree structure, I need to verify if the file already exists in the same folder.

If it is the same file (with the same content) then do nothing.

If it is a different file then save a new version.

How can I compare those files?

Blobs inputBlobs = new Blobs();
inputBlobs.add(file1);
inputBlobs.add(file2);
inputBlobs.add(file3);

nuxeoClient.automation().newRequest("Blob.AttachOnDocument").param("xpath", "files:files").param("document", doc).input(inputBlobs).execute();
0 votes

1 answers

535 views

ANSWER



Hi,

There's no way to do that in Nuxeo. By default the blob is always marked as different when you attach a blob to a document. Indeed, it's costly to check the blob content for each update as blobs can be big, stored somewhere else…

You still can create your own operation to check blob content and then execute your logic (nothing to do or create a version). You can find how to create an operation here.

1 votes



But does it save a new one even if it has the same name?
06/06/2017

I say this because I'm doing tests and he's saving the same file several times (each time I repeat the test)
06/06/2017

Blob.AttachOnDocument will append the blob if the target property is a list, which is the case for files:files.

You can probably create an automation scripting, by following this steps which can get the blobs name by using Blob.Get, test if you have the same name and if not call the operation to attach the blob.

06/07/2017