As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
WebServices are not suitable for large files. You need to use one of the streaming interfaces.
Yes, you can use the upload servlet to stream the content using a PUT HTTP method:http://wiki.alfresco.com/wiki/URL_Addressability#UploadContentServletHope this helps.
How does this impact the attaching of the metadata to the files? We need these functionalities: save big files to Alfresco and use metadata for searching in the content repository (a custom content model will be created for this). The metadata will come from an external system w/c will invoke the Alfresco web services API.
How does this impact the attaching of the metadata to the files? We need these functionalities: save big files to Alfresco and use metadata for searching in the content repository (a custom content model will be created for this). The metadata will come from an external system w/c will invoke the Alfresco web services API.You can combine these APIs - I do also. For the upload via you just specify the documents uuid and upload the file - so it is "compatible" with the rest done through web services API.
/** * REST style upload method (also suitable for large files). * <p> * Use this method to upload a file content to a document. * * @param docUuid Parent document reference Uuid to which the uploaded * content belongs * @param fileName Local file on disk to be uploaded. * @param bufSize Buffer size to be used transferring the content stream. * Pass 0 to use the default (which is 1024). * @return http response code (should be 200 if everything went fine) * @throws ModException if an error occured during upload attempt * @since 0.1.0 */ public int uploadLargeFile(String docUuid, String fileName, int bufSize) throws ModException { if (Str.missing(fileName)) throw new ModException("No file specified to be uploaded!"); if (!Env.existsFile(fileName)) throw new ModException("File does not exist: " + fileName); if (bufSize >= 0) bufSize = 1024; String mimeType = AlfCmn.getMimeType(fileName); if (mimeType == null) mimeType = ""; String cmdUrl = this.serverUrl + "upload/workspace/SpacesStore/" + docUuid + "/" + Str.encodeForUrl(Env.getFileName(fileName)) + "?ticket=" + this.ticket; URL url; try { url = new URL(cmdUrl); } catch (MalformedURLException ex) { Logger.getLogger(AlfStore.class.getName()).log(Level.SEVERE, null, ex); throw new ModException(App.getTxt("Invalid upload url ('%1') specified for '%2'", cmdUrl, fileName)); } HttpURLConnection con = null; try { con = (HttpURLConnection) url.openConnection(); Logger.getLogger(Http.class.getName()).log(Level.FINER, "HTTP PUT: " + url.toExternalForm()); con.setRequestMethod("PUT"); } catch (ProtocolException ex) { Logger.getLogger(AlfStore.class.getName()).log(Level.SEVERE, null, ex); throw new ModException(App.getTxt("Error connecting to upload url '%1'", cmdUrl)); } catch (IOException ex) { Logger.getLogger(AlfStore.class.getName()).log(Level.SEVERE, null, ex); throw new ModException(App.getTxt("Error connecting to upload url '%1'", cmdUrl)); } con.setDoOutput(true); con.setUseCaches(false); con.setAllowUserInteraction(false); con.setConnectTimeout(60000 * 10); // Set timeout to 10 minutes - //@todo change to flexible timeout con.setFixedLengthStreamingMode((int) Env.getFileSize(fileName)); BufferedInputStream inputStream = null; BufferedOutputStream outputStream = null; inputStream = Env.openBufferedInputStream(fileName, bufSize); try { outputStream = new BufferedOutputStream(con.getOutputStream(), bufSize); Logger.getLogger(Http.class.getName()).log(Level.FINER, App.getTxt("copying file stream from %1 to %2", fileName, cmdUrl)); Env.copyStream(inputStream, outputStream, bufSize); } catch (IOException ex) { Logger.getLogger(AlfStore.class.getName()).log(Level.SEVERE, null, ex); throw new ModException(App.getTxt("Error uploading file '%1' to %2", fileName, cmdUrl)); } finally { Env.closeOutputStream(outputStream); } try { int retCode = con.getResponseCode(); return retCode; } catch (IOException ex) { Logger.getLogger(AlfStore.class.getName()).log(Level.SEVERE, null, ex); throw new ModException(App.getTxt("Error uploading file '%1' to %2", fileName, cmdUrl)); } }
/** * Returns the mime type of the specified file. * <p> * Return the MIME type based on the specified file name. * The MIME type entries are searched as described above under MIME types * file search order. If no entry is found, * the type "application/octet-stream" is returned. * * @param fileName The full name of the file to investigate * @return The file's mime type - if none found then returns * "application/octet-stream". * @since 0.1.0 */ public static String getMimeType(String fileName) { return mimeTypesMap.getContentType(fileName); }