cancel
Showing results for 
Search instead for 
Did you mean: 

upload blob/byte[]

Ana_Paula_Lopes
Champ on-the-rise
Champ on-the-rise

Hello everyone, Is it possible to upload a file by just blob or byte [] instead of the file itself ??? See the example below:

private Document exportNuxeo() throws IOException {
		
		
		Document doc = new Document("file", "File");
		doc.set("dc:title", "Documento 1");

		doc = nuxeoClient.repository().createDocumentByPath("/camara.leg/workspaces/", doc);

		Document docCriado = nuxeoClient.repository().fetchDocumentByPath("/camara.leg/workspaces/file");

		Blob fileBlob = new Blob(new File("c:\\Desenvolvimento\\doc-nuxeo\\teste.pdf"));

		nuxeoClient.automation().newRequest("Blob.AttachOnDocument").param("document", docCriado).input(fileBlob)
				.execute();

		return doc;
	}
Blob fileBlob = new Blob(new File("c:\\Desenvolvimento\\doc-nuxeo\\teste.pdf"));

Instead of being the File object being, I use a Blob or byte []

Because I will need to migrate multiple files from the sql server database to nuxeo....

att Ana Paula Lopes Araújo

7 REPLIES 7

Ana_Paula_Lopes
Champ on-the-rise
Champ on-the-rise

someone???

Kevin_Leturc
Star Contributor
Star Contributor

Hello,

This is currently not possible with our java client. I created https://jira.nuxeo.com/browse/JAVACLIENT-125 to add this feature to client. But it may take times to be done. You can create a PR with the feature if you want, have a look at https://doc.nuxeo.com/nxdoc/contributing-to-nuxeo/ before.

Unless, I'm afraid you need to serialize the byte[] to a file in order to upload it. Something like this should work:

FileUtils.writeByteArrayToFile(new File("pathname"), myByteArray)

FileUtils is a class from Apache Common IO, used by the client.

I need to migrate some files (+/- one million and a half) that are in SQL Server to nuxeo ...

I would have these files in blob or byte []

The only way to do this is to write the blob or byte[] to a temporary file and then upload this file by using blob object from nuxeo-java-client.

Do you have any examples using this getByteArray() ???? and could you share it for me?

This isn't nuxeo-related, it's just pure java code. Something like this should work

Getting started

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.