06-16-2015 07:44 AM
public String uploadFile(String idfolder, byte[] bytes, String fileName,
String contentType) {
String idDoc = null;
// properties
Folder folder = (Folder) session.getObject(idfolder);
Map<String, Object> newDocProps = new HashMap<String, Object>();
newDocProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
newDocProps.put(PropertyIds.NAME, fileName);
ContentStream contentStream = new ContentStreamImpl(fileName,
BigInteger.valueOf(bytes.length), contentType,
new ByteArrayInputStream(bytes));
try {
// create the file
Document doc = folder.createDocument(newDocProps, contentStream,
VersioningState.NONE);
idDoc = doc.getId();
} catch (CmisConstraintException e) {
System.out.println("No se pudo crear el archivo");
}
return idDoc;
}
06-16-2015 12:23 PM
Folder folder = (Folder) session.getObject(idfolder);
06-16-2015 12:35 PM
public void handleFileUpload(FileUploadEvent event) throws IOException {
this.file = event.getFile();
fichero = event.getFile().getContents();/* Byte */
nombreFichero = file.getFileName();
tipoFichero = file.getContentType();
directorioAlfrescoDocumento= "/carpetaDeseada/";
Controller(); /*me conecto con alfresco*/
idDocumentoEnAlfresco = uploadFile(directorioAlfrescoDocumento, fichero, nombreFichero,tipoFichero);
}
public String uploadFile(String idfolder, byte[] bytes, String fileName,
String contentType) {
String idDoc = null;
// properties
Folder folder = (Folder) session.getObject(idfolder); /*error*/
Map<String, Object> newDocProps = new HashMap<String, Object>();
newDocProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
newDocProps.put(PropertyIds.NAME, fileName);
ContentStream contentStream = new ContentStreamImpl(fileName,
BigInteger.valueOf(bytes.length), contentType,
new ByteArrayInputStream(bytes));
try {
// create the file
Document doc = folder.createDocument(newDocProps, contentStream,
VersioningState.NONE);
idDoc = doc.getId();
} catch (CmisConstraintException e) {
System.out.println("No se pudo crear el archivo");
}
return idDoc;
}
06-17-2015 03:32 AM
06-17-2015 03:29 AM
06-17-2015 04:51 AM
String path = "/User Homes/folder"
CmisObject object = getSession().getObjectByPath(path);
String id = object.getId();
06-17-2015 06:49 AM
String path = "/index/2015/";
CmisObject object = session.getObjectByPath(path);
//Sera carpeta ¿?
if (object instanceof Folder) {
// Nombre del documento
String name = file.getFileName();
String type = file.getContentType();
byte[] data2 = fichero;
Map<String, Object> properties2 = new HashMap<String, Object>();
properties2.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
properties2.put(PropertyIds.NAME, name);
// Se carga el contenido en un ContentStream
InputStream stream = new ByteArrayInputStream(data2);
ContentStream contentStream = new ContentStreamImpl(name,
BigInteger.valueOf(data2.length),type, stream);
// Se crea el documento
Document newDoc = ((Folder) object).createDocument(properties2,
contentStream, VersioningState.MAJOR);
06-17-2015 08:57 AM
urlElemento=newDoc.getContentUrl();
06-17-2015 09:00 AM
06-19-2015 03:47 AM
Tags
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.