/// <summary> /// This method returns the public URL of a DropBox file or folder /// </summary> /// <param name="token"></param> /// <param name="fsEntry"></param> /// <returns></returns> static public Uri GetPublicObjectUrl(ICloudStorageAccessToken token, ICloudFileSystemEntry fsEntry) { // check parameters if (fsEntry == null) { throw new SharpBox.Exceptions.SharpBoxException(AppLimit.CloudComputing.SharpBox.Exceptions.SharpBoxErrorCodes.ErrorInvalidParameters); } // get the resource path String resourcePath = GenericHelper.GetResourcePath(fsEntry); // check if it is a public dir if (!resourcePath.ToLower().Contains("/public/")) { throw new SharpBox.Exceptions.SharpBoxException(AppLimit.CloudComputing.SharpBox.Exceptions.SharpBoxErrorCodes.ErrorInvalidParameters); } // get accoutn inf DropBoxAccountInfo accInfo = GetAccountInformation(token); // http;//dl.dropbox.com/u/" + userid / + folder + filename String uri = "http://dl.dropbox.com/u/" + accInfo.UserId.ToString() + resourcePath.Replace("/Public", ""); // go ahead return(new Uri(uri)); }
/// <summary> /// This method returns the account information of a dropbox account /// </summary> /// <param name="token"></param> /// <returns></returns> static public DropBoxAccountInfo GetAccountInformation(ICloudStorageAccessToken token) { // generate the dropbox service DropBoxStorageProviderService service = new DropBoxStorageProviderService(); // generate a session IStorageProviderSession session = service.CreateSession(token, DropBoxConfiguration.GetStandardConfiguration()); if (session == null) { return(null); } // receive acc info DropBoxAccountInfo accInfo = service.GetAccountInfo(session); // close the session service.CloseSession(session); // go ahead return(accInfo); }