DriveFarm API


Published on

The developers, with DriveFarm API, are able to create new app and corporate services interacting with secure file server in the cloud.
If you have service for SME and you need storage area, DriveFarm is the perfect service for you!

DriveFarm is a new cloud File Server for business, projected and developed to help small and medium companies in the daily maintenance of their document assets. 
With DriveFarm they can optimize their company procedures, share projects, contracts and catalogues with their team through:
- a unique repository, always accessible through mobile or web;

- a dedicated app, easing your work through mobility;

- permission control to modifying your documents;

- a control system for a correct use of your company documents.


Contrary to other file managers, DriveFarm allows the management and personalization of every single employee profile and correlated privileges. For every worker, the company manager or its IT Manager can define:
- storage characteristics and dimensions;

- level of documents sharing with contacts out of the company;

- mobile devices access to file server;

- out of the company access via web.

DriveFarm grants an elevated data security, thanks to its real time replica into datacenters, geographically situated in different locations. DriveFarm is furthermore projected to transfer files through secure connections (HTTPS) and to protect the customers informations through three security levels (infrastructure, apps and human).

FILE SHARE & TRACK with DriveFarm
Every company member can share his/her files and documents with other internal or external colleagues, directly from Web or Mobile App. Compared to other cloud file managers, DriveFarm tracks files sharing and sending activities, respecting privacy rules. The company manager can verify members usage of documents assets and identify any compliant activity.

1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • DriveFarm API

    1. 1. Stefano DindoMail: s.dindo@zero12.itTwitter: @stefanodindo
    2. 2. Corporate 1 Corporate 2 Corporate N ...Hierarchical organization of users in the company Admin Admin Admin Clerk Users Clerk Users Clerk Users
    3. 3. API
    4. 4. OAuth 2.0 (1) Redirect su Login Page (2) Response code Client App (3) The codice is passed to the Server (4) getToken(code) (5) Response is sent access_token (6) API method are colled by access_token (7) Response is sent in JSON format Server App
    5. 5. List the contents of the root folderJava PythonString result = null; import urllibString urlStr = "" + import httplib "/folderContent?accessToken=ACCESS_TOKEN&path=/"; import jsontry { data = {} URL url = new URL(urlStr); data[accessToken] = ’ACCESS_TOKEN    URLConnection conn = url.openConnection(); data[path] = /    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); headers = {"Accept": "application/json"}    StringBuffer sb = new StringBuffer(); query = urllib.urlencode(data)    String line;    while ((line = rd.readLine()) != null) { conn = httplib.HTTPSConnection("")        sb.append(line); conn.request("GET", "/api/folderContent?" + query, None, hea    } response = conn.getresponse()    rd.close(); data = conn.close()    result = sb.toString();} for f in json.loads(data)[files]:catch (Exception e){ print f[path] // ...}System.out.println(result);/// parsing JSON
    6. 6. Folder creationJava PythonString url="”; import urllibString body = "{ "accessToken" : ”ACCESS_TOKEN", " + import httplib ""path" : "/Path/To/Folder" }"; import jsonURL serverAddress = new URL(url); data = {} data[accessToken] = ’ACCESS_TOKENHttpURLConnection connection = data[path] = /Path/To/Folder (HttpURLConnection) serverAddress.openConnection();connection.setDoInput(true); headers = {"Content-type": "application/json",connection.setDoOutput(true); " "Accept": "application/json"}connection.setUseCaches(false);        connection.setRequestProperty("Content-Type”, conn = httplib.HTTPSConnection("") "application/json"); conn.request("POST", "/api/createFolder", json.dumps(data), headers)connection.setRequestProperty("Accept", "application/json"); response = conn.getresponse()connection.setRequestMethod("POST"); status = response.statusconnection.connect(); data =        conn.close()DataOutputStream dos = new DataOutputStream(connection.getOutputStream() ); print json.loads(data)dos.write(body.getBytes());dos.close();BufferedReader br = new BufferedReader( new InputStreamReader(connection.getInputStream()));StringBuffer sb = new StringBuffer();String str = br.readLine();while(str != null){    sb.append(str);  str = br.readLine();}br.close();System.out.println(sb.toString());
    7. 7. File uploadJava PythonString url="”; import urllib import httplib// ... import jsonString boundary = "AaB03x"; import osint totalBodyLength = ... import stat// ... BODY = --AaB03xrnconnection.setRequestProperty("Content-Type”, BODY = BODY + Content-Disposition: form-data; name="fileUpload"r multipart/form-data; boundary=" + boundary); nconnection.setRequestProperty("Content-Length", totalBodyLength); BODY = BODY + rnconnection.setRequestProperty("Accept", "application/json"); BODY = BODY + %srnconnection.setRequestMethod("POST"); BODY = BODY + --AaB03xrnconnection.connect(); BODY = BODY + Content-Disposition: form-data; name="uploadedFile"r        nDataOutputStream dos = BODY = BODY + Content-Type: application/octet-streamrn new DataOutputStream(connection.getOutputStream()); BODY = BODY + rndos.writeBytes("--" + boundary + lineEnd); BODY = BODY + %srndos.writeBytes("Content-Disposition: form-data; "+ BODY = BODY + --AaB03x--rn " name="fileUpload"" + lineEnd);dos.writeBytes(lineEnd); data = {}dos.write(body.getBytes()); data[accessToken] = ‘ACCESS_TOKENdos.writeBytes(lineEnd); data[path] = /Path/To/Folder/file.txtdos.writeBytes( "--"+boundary + lineEnd); data[size] = os.stat(icon.png)[stat.ST_SIZE]dos.writeBytes("Content-Disposition: form-data; "+ "name="uploadedFile"" + lineEnd); f = open(‘file.txt, rb)dos.writeBytes("Content-Type: application/octet-stream"+ lineEnd); body = BODY % (json.dumps(data),; f.close()// scrittura contenuto filedos.writeBytes(lineEnd); headers = {"Content-type": "multipart/form-data; boundary=AaB03x",dos.writeBytes( "--" + boundary + "--"+ lineEnd); "Content-Length": "%d" % len(body),dos.flush(); "Accept": "application/json"}dos.close(); conn = httplib.HTTPSConnection("")// lettura risposta JSON conn.request("POST", "/api/fileUpload", body, headers) response = conn.getresponse() status = response.status data = conn.close() print json.loads(data)
    8. 8. Example of upload with browser<html><head> <title>POST Test</title></head><body> <form action="" enctype="multipart/form-data" method="post"> <table> <tr> <!-- Campo HTML in cui inserire i dati JSON formattati. Esempio: {"accessToken":”ACCESS_TOKEN","size":1234,"path":"/path/to/file.txt"} --> <td>fileUpload</td> <td><input type="text" name="fileUpload"/></td> </tr> <tr> <td>uploadedFile</td> <td><input type="file" name="uploadedFile"/></td> </tr> <tr> <td colspan="2"><input type="submit" value="invia"/></td> </tr> </table> </form></body></html>
    9. 9. Request authorization + Request access token after user confirmation urllibimport httplibimport jsondata = {}data[client_id] = CLIENT_IDdata[client_secret] = CLIENT_SECRECTdata[grant_type] = authorization_codedata[redirect_uri] = REDIRECT_URIdata[code] = codeprint urllib.urlencode(data)headers = {"Content-type": "application/x-www-form-urlencoded"," "Accept": "application/json"}conn = httplib.HTTPSConnection("")conn.request("POST", "/api/access", urllib.urlencode(data), headers)response = conn.getresponse()status = response.statusdata = data
    10. 10. GrazieStefano DindoMail: s.dindo@zero12.itTwitter: @stefanodindo