public static string UploadInDropbox(string fileName, Stream stream, int fileSize, bool isUserPicture = false) { DropNetClient client = new DropNetClient(DropboxAppKey, DropboxAppSecret, DropboxUserKey, DropboxUserSecret); client.UseSandbox = true; var bytes = new byte[fileSize]; stream.Read(bytes, 0, fileSize); var currentTicks = DateTime.Now.Ticks; client.UploadFile("/", currentTicks + fileName, bytes); if (isUserPicture) { return client.GetMedia(string.Format("/{0}", currentTicks + fileName)).Url; } else { return client.GetShare(string.Format("/{0}", currentTicks + fileName)).Url; } }
private string UploadImage(string username, HttpPostedFileBase file) { const string apiKey = "l4nimqeeebndlvk"; const string appSecret = "hc00vzx5jhh5gsy"; const string clientKey = "w6efv2ke7212uc6c"; const string clientSecret = "bpucboq34ndlxos"; DropNetClient client = new DropNetClient(apiKey, appSecret, clientKey, clientSecret); string path = "/images/user_" + username.ToLower(); string filename = "img_" + Guid.NewGuid() + file.FileName.Substring(file.FileName.LastIndexOf('.')); DropNet.Models.MetaData metaData = client.UploadFile(path, filename, file.InputStream); DropNet.Models.ShareResponse response = client.GetMedia(metaData.Path); return response.Url; }
private static string UploadInDropbox(string fileName, Stream stream, int fileSize) { DropNetClient client = new DropNetClient(DropboxAppKey, DropboxAppSecret, DropboxUserKey, DropboxUserSecret); client.UseSandbox = true; var bytes = new byte[fileSize]; stream.Read(bytes, 0, fileSize); client.UploadFile("/", fileName, bytes); return client.GetMedia("/" + fileName).Url; }
public String GetMedialUrl(string path, AuthCredential credential) { if (String.IsNullOrEmpty(path)) { return null; } var _client = new DropNetClient(MogConstants.DROPBOX_KEY, MogConstants.DROPBOX_SECRET); UserLogin User = new UserLogin() { Token = credential.Token, Secret = credential.Secret }; _client.UserLogin = User; _client.UseSandbox = true; ShareResponse response = _client.GetMedia(path); return (response != null ? response.Url : null); }