Dll: Dropbox API

Plugins y todo lo relacionado para Autoplay Media Studio.
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 + "\"}";
}
;) como siempre el puto!!!
Mmm Tengo que ver esto ... No entiendo mucho pero aprendo rapido .... ;) Muchas Gracias Ceone y Pabloko los mejores
thanx ya me3alem

------------------
gracias por este plugin
:yes:
thanks Imagen
muy buen ejemplo
aver de que trata gracias
gracias voy a analizarlo :D
gracias!
cool
c
la verdad no se lo que hace pero Parece interesante...
gracias
need API Plugins to used ?
the only requeriment for this is .net framework 3.5 (included in vista/seven)
thank you
thanx ya me3alem
Haberlo... :)
tooooo