Exemple #1
0
        async Task Login(IShareFileClient api)
        {
            var homeFolder = await api.Sessions.Get().Project(session =>
                                                              ((ShareFile.Api.Models.User)session.Principal).HomeFolder).ExecuteAsync();

            txtSfPath.Text = homeFolder.Id;
        }
 internal AsyncFileDownloader(Item item, IShareFileClient client, DownloaderConfig config = null)
     : base(item, client, config)
 {
     Client = client;
     Config = config ?? DownloaderConfig.Default;
     Item   = item;
 }
Exemple #3
0
        void ChooseDirectory_Load(object sender, EventArgs e)
        {
            ShareFile.Sync.Authentication.WebpopBrowser.SetUseCurrentIERegistryKey();
            var webpop = new WebpopForm();

            webpop.browser.Finished += async(browser, args) =>
            {
                if (args.Success)
                {
                    this.Text           = String.Format("Onboarding: {0}.{1}", args.AuthCode.Subdomain, args.AuthCode.ApplicationControlPlane);
                    lblProgress.Text    = "Logging in...";
                    lblProgress.Visible = true;
                    webpop.Close();
                    api = await BuildShareFileClient(args.AuthCode);

                    btnUpload.Enabled   = true;
                    lblProgress.Visible = false;
                }
                else
                {
                    var authFailedAction = MessageBox.Show(this, String.Format("{0}: {1}", args.Error.Error, args.Error.ErrorDescription),
                                                           "Login Failed", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    if (authFailedAction == DialogResult.Retry)
                    {
                        webpop.WebpopForm_Load(null, new EventArgs());
                    }
                    else
                    {
                        this.Close();
                    }
                }
            };
            webpop.ShowDialog(this);
        }
 public AsyncFileDownloader(Item item, IShareFileClient client, DownloaderConfig config = null)
     : base (item, client, config)
 {
     Client = client;
     Config = config ?? DownloaderConfig.Default;
     Item = item;
 }
Exemple #5
0
 protected DownloaderBase(Item item, IShareFileClient client, DownloaderConfig config = null)
 {
     Client           = client;
     Item             = item ?? throw new ArgumentNullException(nameof(item));
     Config           = config ?? new DownloaderConfig();
     progressReporter = new TransferProgressReporter(
         fileSize: BytesToDownload() ?? 0,
         transferId: "",
         reportInterval: Config.ProgressReportInterval);
 }
Exemple #6
0
 protected DownloaderBase(DownloadSpecification downloadSpecification, IShareFileClient client, DownloaderConfig config = null)
 {
     Client = client;
     Config = config ?? new DownloaderConfig();
     DownloadSpecification = downloadSpecification ?? throw new ArgumentNullException(nameof(downloadSpecification));
     progressReporter      = new TransferProgressReporter(
         fileSize: BytesToDownload() ?? 0,
         transferId: "",
         reportInterval: Config.ProgressReportInterval);
 }
Exemple #7
0
// ReSharper restore InconsistentNaming

        protected QueryBase(IShareFileClient client)
        {
            Client = client;

            _queryString      = new ODataParameterCollection();
            _ids              = new ODataParameterCollection();
            _subActions       = new List <ODataAction>();
            _headerCollection = new Dictionary <string, string>();

            HttpMethod = "GET";
        }
Exemple #8
0
        public async Task <IShareFileClient> GetClientAsync()
        {
            try
            {
                await _instance.Accounts.Get().ExecuteAsync();
            }
            catch (Exception ex) when(ex is WebAuthenticationException || ex is NullReferenceException)
            {
                _instance = await GetAuthenticatedClient();
            }

            return(_instance);
        }
Exemple #9
0
        public AsyncMemoryMappedFileDownloader(Item item, IShareFileClient client, DownloaderConfig config = null)
            : base(item, client, config)
        {
            if (Config.RangeRequest != null)
            {
                throw new ArgumentException($"{nameof(AsyncMemoryMappedFileDownloader)} does not support {nameof(RangeRequest)}", $"{nameof(DownloaderConfig)}");
            }
            if (!item.FileSizeBytes.HasValue)
            {
                throw new ArgumentException($"{nameof(Item)} must include {nameof(Item.FileSizeBytes)}", $"{nameof(Item)}");
            }

            fileSize = item.FileSizeBytes.Value;
        }
Exemple #10
0
        public Uploader(IShareFileClient api)
        {
            this.api            = api;
            standardUploadQueue = new AsyncSemaphore(MAX_CONCURRENT_STANDARD_UPLOAD);
            threadedUploadQueue = new AsyncSemaphore(MAX_CONCURRENT_THREADED_UPLOAD);

            threadedUploaderConfig = new Api.Client.Transfers.Uploaders.FileUploaderConfig
            {
                NumberOfThreads = MAX_CONCURRENT_STANDARD_UPLOAD / MAX_CONCURRENT_THREADED_UPLOAD,
                PartConfig      = new Api.Client.Transfers.Uploaders.FilePartConfig
                {
                    InitialPartSize = (int)STANDARD_UPLOADER_MAX_FILE_SIZE,
                    MaxPartSize     = (int)(4 * STANDARD_UPLOADER_MAX_FILE_SIZE),
                }
            };
        }
        private Task <Share> GetShareAsync(IShareFileClient client, Item file)
        {
            var share = new Share
            {
                Items = new List <Item> {
                    file
                },
                RequireUserInfo = false,
                RequireLogin    = false,
                ShareType       = ShareType.Send,
                Title           = $"Share for {file.Name}",
                ExpirationDate  = DateTime.Now.AddDays(10),
                MaxDownloads    = -1
            };

            return(client.Shares.Create(share).ExecuteAsync());
        }
Exemple #12
0
 public RemoteUploadsEntity(IShareFileClient client)
     : base(client, "RemoteUploads")
 {
 }
Exemple #13
0
 public AppsEntity(IShareFileClient client)
     : base(client, "Apps")
 {
 }
 public FileDownloader(Item item, IShareFileClient client, DownloaderConfig config = null)
     : base(item, client, config)
 {
 }
Exemple #15
0
 public StreamQuery(IShareFileClient client) : base(client)
 {
 }
 public SessionsEntity(IShareFileClient client)
     : base(client, "Sessions")
 {
 }
Exemple #17
0
 public AccountsEntity(IShareFileClient client)
     : base(client, "Accounts")
 {
 }
 public MetadataEntity (IShareFileClient client)
     : base (client, "Metadata")
 { }
 public FolderTemplatesEntity (IShareFileClient client)
     : base (client, "FolderTemplates")
 { }
Exemple #20
0
 public ZonesEntity (IShareFileClient client)
     : base (client, "Zones")
 { }
Exemple #21
0
 public PoliciesEntity(IShareFileClient client)
     : base(client, "Policies")
 {
 }
Exemple #22
0
 public DevicesEntity(IShareFileClient client)
     : base(client, "Devices")
 {
 }
 public AsyncOperationsEntity (IShareFileClient client)
     : base (client, "AsyncOperations")
 { }
Exemple #24
0
 public WorkflowsEntity(IShareFileClient client)
     : base(client, "Workflows")
 {
 }
 public AccessControlsEntity(IShareFileClient client)
     : base(client, "AccessControls")
 {
 }
 public UsersEntity(IShareFileClient client)
     : base(client, "Users")
 {
 }
 public ConnectorGroupsEntity (IShareFileClient client)
     : base (client, "ConnectorGroups")
 { }
 public ConnectorGroupsEntity(IShareFileClient client)
     : base(client, "ConnectorGroups")
 {
 }
 public OAuthService(IShareFileClient shareFileClient, string clientId, string clientSecret)
 {
     ClientId        = clientId;
     ClientSecret    = clientSecret;
     ShareFileClient = shareFileClient;
 }
Exemple #30
0
 protected EntityBase(IShareFileClient client, string entity)
 {
     Client = client;
     Entity = entity;
 }
 public AsyncFileDownloader(DownloadSpecification downloadSpecification, IShareFileClient client, DownloaderConfig config = null)
     : base(downloadSpecification, client, config)
 {
 }
 public SharesEntity(IShareFileClient client)
     : base(client, "Shares")
 {
 }
 protected DownloaderBase(Item item, IShareFileClient client, DownloaderConfig config = null)
 {
     Client = client;
     Item = item;
     Config = config ?? new DownloaderConfig();
 }
Exemple #34
0
 public FormQuery(IShareFileClient client) : base(client)
 {
 }
 protected SyncDownloaderBase(Item item, IShareFileClient client, DownloaderConfig config = null)
     : base(item, client, config)
 {
 }
 public FavoriteFoldersEntity (IShareFileClient client)
     : base (client, "FavoriteFolders")
 { }
 public OAuthService(IShareFileClient shareFileClient, string clientId, string clientSecret)
 {
     ClientId = clientId;
     ClientSecret = clientSecret;
     ShareFileClient = shareFileClient;
 }
 public GroupsEntity(IShareFileClient client)
     : base(client, "Groups")
 {
 }
 public SharesEntity(IShareFileClient client)
     : base(client, "Shares")
 {
 }
 public StorageCentersEntity (IShareFileClient client)
     : base (client, "StorageCenters")
 { }
 protected DownloaderBase(Item item, IShareFileClient client, DownloaderConfig config = null)
 {
     Client = client;
     Item   = item;
     Config = config ?? new DownloaderConfig();
 }
 public AsyncFileDownloader(Item item, IShareFileClient client, DownloaderConfig config = null)
     : base(item, client, config)
 {
 }
Exemple #43
0
 public WebhookClientsEntity(IShareFileClient client)
     : base(client, "WebhookClients")
 {
 }
 public SessionsEntity(IShareFileClient client)
     : base(client, "Sessions")
 {
 }
 public CapabilitiesEntity (IShareFileClient client)
     : base (client, "Capabilities")
 { }
 public AccessControlsEntity (IShareFileClient client)
     : base (client, "AccessControls")
 { }
 public AccountsEntity (IShareFileClient client)
     : base (client, "Accounts")
 { }
Exemple #48
0
 public MetadataEntity(IShareFileClient client)
     : base(client, "Metadata")
 {
 }
 public FavoriteFoldersEntity(IShareFileClient client)
     : base(client, "FavoriteFolders")
 {
 }
 public ReportsEntity (IShareFileClient client)
     : base (client, "Reports")
 { }
 public ItemsEntity(IShareFileClient client)
     : base(client, "Items")
 {
 }