Monday, March 14, 2011

Funny Wedding Card Sayings

Simple Uploaders for Alfresco

NOTE: translation of the original article in English Uploaders simples en alfresco of Zylk.net . Thanks to Toni for reporting this article.

One of the most interesting features of the Alfresco ECM is the variety of protocols that allow you to authenticate and perform actions on the repository, through shared network drives or other APIs. This is mainly due to the use of standard, medium and long-term becomes a clear technological advantage over other more closed stack, and allows integration with all sorts of third-party tools. Among these protocols (and APIs), we can highlight: WebDAV, FTP, CIFS, NFS, IMAP, REST, SOAP e CMIS.

Ignorando le unità di rete CIFS e NFS e lasciando da parte per ora il metodo di caricare i dati tramite e-mail, possiamo creare uploaders tramite numerosi protocolli quali WebDAV, FTP, o REST con poco sforzo. Ad esempio, con il comando curl posso utilizzare il canale FTP come segue:
   curl -T sinadura3.tgz ftp://alfie.zylk.net/Alfresco/sinadura --user cesar:secret   
O meglio ancora, usare il canale WebDAV , che può garantire più sicurezza:
   curl -T sinadura3.tgz https://alfie.zylk.net/alfresco/webdav/sinadura --user cesar:secret   
Un'altra opzione layer is to use REST with a little script that calls curl to send the file in question:
  # / bin / bash # 

# Alfresco upload script with CURL by LouiSe@louise.hu

# # Usage : alfresco_uploader.sh

# #. / alfresco_uploader.sh / tmp / some.pdf somes documentLibrary somedir
#

ALFRESCO_SERVER = "http://alfie.zylk.net:8080/alfresco"
USERNAME = "cesar"
PASSWORD = "secret" #

CURL_VERBOSE
CURL_VERBOSE =- v =- s =
CURL_METHOD POST
FILENAME = `basename $ 1`
MIMETYPE = `file - brief - mime-type = $ 1`
UPLOAD_SERVICE_URL ALFRESCO_SERVER {$} / service / api / upload

echo "Uploading $ {FILENAME} ($ MIMETYPE) ALFRESCO_SERVER to $ {}"

CURL_VERBOSE} {$ curl-k-X $ CURL_METHOD} {\\
- user "$ {USERNAME }":"${ PASSWORD} "\\
-F Filedata = @ $ 1-F siteid =" $ 2 "-F containerid =" $ 3 "\\
-F uploaddirectory =" $ 4 "\\-F filename =" $ {FILENAME} "\\
-F ContentType = "$ {MIMETYPE}" "$ {UPLOAD_SERVICE_URL} \\
CMIS
with a little script in python (with libraries
cmislib
).
#! / Usr / bin / python import
from cmislib.model CmisClient
from sys import argv CmisClient client = ('http://alfie.zylk.net:8080/alfresco/service/cmis',' cesar ',' secret ') repo = client.defaultRepository someFolder repo.getObjectByPath ('/'+ = argv [2])
someFolder.getTitle ()
someFolder.getProperties ()
 
somefile = open (argv [1],' r ' )
someDoc someFolder.createDocument = (argv [1] = somefile contentFile)


or the equivalent in PHP: require_once



('cmis_repository_wrapper.php');
$repo_url = "http://alfie.zylk.net:8080/alfresco/service/cmis";
$repo_username = "cesar";
$repo_password = "secret";
$filename = $_SERVER["argv"][1];
$repo_folder = $_SERVER["argv"][2];

if ($repo_username == "alf_ticket") {
   $client = new CMISService($repo_url, null, null, array ( $repo_username => $repo_password ));  } else { 
$client = new CMISService($repo_url, $repo_username, $repo_password);
}

$myfolder = $client->getObjectByPath($repo_folder);
$ File = fopen ($ filename, "r");
$ contents = fread ($ file, filesize ($ filename));
$ fi = new finf (FILEINFO_MIME, '/ usr / share / file / magic');
$ mime_type = $ fi-> buffer (file_get_contents ($ filename));

fclose ($ file);

obj_doc $ = $ client-> createDocument ($ myfolder-> id, $ filename, array (), $ contents, $ mime_type);




0 comments:

Post a Comment