Create version programmatically and update binary content
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2014 04:27 PM
Instead of uploading new version via alfresco share interface, a group of files have been mistakenly uploaded by the graphic department straight into an alfresco folder.
Therefore the only option I have, is to download each file, and load them one by one into the proper version.
It would be great if this could be done via Javascript API. I see there a specific version api, but I couldn't find a way to upload the content of the file.
This is what I have tried, but it results in the file being corrupted. I hope I made myself clear about what I am trying to achieve.
Therefore the only option I have, is to download each file, and load them one by one into the proper version.
It would be great if this could be done via Javascript API. I see there a specific version api, but I couldn't find a way to upload the content of the file.
This is what I have tried, but it results in the file being corrupted. I hope I made myself clear about what I am trying to achieve.
// the original file to be versioned (jpg)var originId = "workspace://SpacesStore/08244ba1-a795-4751-9052-cd236a532820";// the file uploaded by the graphic department (jpg)var versionId = "workspace://SpacesStore/a6b0f218-9d3a-4fe3-be1f-1a1cd192212d";var origin = search.findNode(originId);var version = search.findNode(versionId);var newVersion = origin.createVersion("new version",false);var newFile = search.findNode(newVersion.nodeRef);newFile.content= version.content;// if succeed delete versionId…
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2015 08:23 AM
The following code should work:
var originId = "workspace://SpacesStore/08244ba1-a795-4751-9052-cd236a532820";// the file uploaded by the graphic department (jpg)var versionId = "workspace://SpacesStore/a6b0f218-9d3a-4fe3-be1f-1a1cd192212d"; var origin = search.findNode(originId);var version = search.findNode(versionId);var newVersion = origin.createVersion("new version",false);origin.properties.content.write(version.properties.content);
