Página 1 de 6

Dll: Dropbox API

Publicado: 22 Abr 2011 21:51
por Pabloko
He ido haciendo esto en ratitos, ceone me ha hechado una mano con el ejemplo apz

La dll que lo controla esta hecha en c# esta concretamente necesita del runtime .net 3.5 para funcionar por alguna de sus dependencias que lo requiere, estas estan en la misma carpeta root, son 3 dll, ademas de la principal ubicada en la carpeta docs

Poco mas que explicar...

Viene con una cuenta que ha crado ceone para el foro, no joderla

Hay que generar apykey y secretkey en dropbox, area developers>my apps creamos un app y al final aparecen las dos contraseñas

Metodos:
1/0=CanLongin(apikey,secretkey,email,password) //testea el login

Upload(apikey,secretkey,email,password,archivo_local,carpeta_destino) //subir archivo

Delete(apikey,secretkey,email,password,archivo_o_carpeta) //elimina archivo o carpeta

String=GetMetaData(apikey,secretkey,email,password,path) //obtiene los archivos y carpetas de un directorio

String=GetFileData(apikey,secretkey,email,password,path) //obtiene un listado de parametros del archivo

String=GetFile(apikey,secretkey,email,password,path) //obtiene contenido de archivo

GetFileSave(apikey,secretkey,email,password,path,destino) //obtiene archivo y lo guarda

Move(apikey,secretkey,email,password,from,to) //mueve archivos

string=AccountInfo(apikey,secretkey,email,password) //obtiene listado de informacion de usuario
todo por stdcall, como en el ejemplo



Descarga:
HIDE: ON
Hidebb Message Hidden Description

mirror :
HIDE: ON
Hidebb Message Hidden Description


Codigo fuente:
[DllExport("CanLogin", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static int CanLogin(string apikey, string secretkey, string username, string password)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
var user = _client.Login(username, password);


if (user!=null && user.Secret!=null && user.Token!=null)
{
return 1;
}
else
{
return 0;
}
}



[DllExport("Upload", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static void Upload(string apikey, string secretkey, string username, string password, string file, string path)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
FileInfo ffile = new FileInfo(file);
byte[] content = _client.GetFileContentFromFS(ffile);
_client.UploadFile(path, ffile.Name, content);

}

[DllExport("UploadAsync", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static void UploadAsync(string apikey, string secretkey, string username, string password, string file, string path)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
FileInfo ffile = new FileInfo(file);
byte[] content = _client.GetFileContentFromFS(ffile);
_client.UploadFile(path, ffile.Name, content);
_client.UploadFileAsync(path, ffile.Name, content, Can_Upload_File_Async_Callback);

}

static void Can_Upload_File_Async_Callback(RestSharp.RestResponse response)
{

}

[DllExport("Delete", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static void delete(string apikey, string secretkey, string username, string password, string file)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
_client.Delete(file);

}

[DllExport("CreateFolder", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static void createfolder(string apikey, string secretkey, string username, string password, string path)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
_client.CreateFolder(path);

}

[DllExport("GetMetaData", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static string getmetadata(string apikey, string secretkey, string username, string password, string path)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
var md = _client.GetMetaData(path);
string retorno="";
for (int i = 0; i < md.Contents.Count; i++)
{
if (i == 0)
{
retorno += md.Contents.Name;
}
else
{
retorno += "|" + md.Contents.Name;
}

}
return retorno;
}


[DllExport("GetFileData", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static string getfiledata(string apikey, string secretkey, string username, string password, string path)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
var fs = _client.GetFile(path);
//var fs = _client.DownloadFile(path);
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
string str = enc.GetString(fs);
return str;
}

[DllExport("GetFile", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static string getfile(string apikey, string secretkey, string username, string password, string path)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
//var fs = _client.GetFile(path);
var fs = _client.DownloadFile(path);
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
string str = enc.GetString(fs);
return str;
}

[DllExport("GetFileSave", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static void getfilesave(string apikey, string secretkey, string username, string password, string path, string save)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
//var fs = _client.GetFile(path);
var fs = _client.DownloadFile(path);
var writeStream = new FileStream(save, FileMode.Create, FileAccess.Write);

writeStream.Write(fs, 0, fs.Length);
writeStream.Close();

}


[DllExport("Move", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static void move(string apikey, string secretkey, string username, string password, string from, string to)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
_client.Move(from, to);
}

[DllExport("AccountInfo", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static string accountinfo(string apikey, string secretkey, string username, string password)
{
DropNetClient _client;
_client = new DropNetClient(apikey, secretkey);
_client.Login(username, password);
var ai = _client.Account_Info();
return "{id=\"" + ai.uid + "\", Name=\"" + ai.display_name + "\", Email=\"" + ai.email + "\", Country=\"" + ai.country + "\", Quota=\"" + ai.quota_info.quota + "\"}";
}

Re: Dropbox api dll

Publicado: 22 Abr 2011 22:23
por Ceone
;) como siempre el puto!!!

Re: Dropbox api dll

Publicado: 22 Abr 2011 22:40
por Thedary
Mmm Tengo que ver esto ... No entiendo mucho pero aprendo rapido .... ;) Muchas Gracias Ceone y Pabloko los mejores

Re: Dropbox api dll

Publicado: 24 Abr 2011 17:06
por ahmed elsayed
thanx ya me3alem

------------------
gracias por este plugin

Re: Dropbox api dll

Publicado: 25 Abr 2011 14:29
por underdead
:yes:

Re: Dropbox api dll

Publicado: 28 Abr 2011 15:55
por dangngocnguyenit
thanks Imagen

Re: Dropbox api dll

Publicado: 30 Abr 2011 18:25
por Buffalo
muy buen ejemplo

Re: Dropbox api dll

Publicado: 30 Abr 2011 20:50
por diabolizar
aver de que trata gracias

Re: Dropbox api dll

Publicado: 01 May 2011 20:13
por yoolordhunt
gracias voy a analizarlo :D

Re: Dropbox api dll

Publicado: 02 May 2011 12:33
por er_mejor
gracias!

Re: Dropbox api dll

Publicado: 03 May 2011 07:36
por Phaelitico
cool

Re: Dll: Dropbox API

Publicado: 24 May 2011 21:49
por patch
c

Re: Dll: Dropbox API

Publicado: 11 Jun 2011 22:24
por sSantoss
la verdad no se lo que hace pero Parece interesante...

Re: Dll: Dropbox API

Publicado: 14 Jun 2011 04:25
por xxsolracxx
gracias

Re: Dll: Dropbox API

Publicado: 08 Jul 2011 14:48
por nghethihieu
need API Plugins to used ?

Re: Dll: Dropbox API

Publicado: 08 Jul 2011 21:28
por Pabloko
the only requeriment for this is .net framework 3.5 (included in vista/seven)

Re: Dll: Dropbox API

Publicado: 24 Jul 2011 16:14
por abood1987
thank you

Re: Dll: Dropbox API

Publicado: 28 Jul 2011 05:22
por bariza-dz
thanx ya me3alem

Re: Dll: Dropbox API

Publicado: 25 Ago 2011 05:32
por DaLion
Haberlo... :)

Re: Dll: Dropbox API

Publicado: 27 Sep 2011 12:33
por bumbo
tooooo