Esempio n. 1
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (!CheckAuthorization())
            {
                return(null);
            }

            if (string.IsNullOrEmpty(FolderID))
            {
                FolderID = "0";
            }

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("parent_id", FolderID);

            UploadResult result = UploadData(stream, "https://upload.box.com/api/2.0/files/content", fileName, "filename", args, GetAuthHeaders());

            if (result.IsSuccess)
            {
                BoxFileInfo fileInfo = JsonConvert.DeserializeObject <BoxFileInfo>(result.Response);

                if (fileInfo != null && fileInfo.entries != null && fileInfo.entries.Length > 0)
                {
                    BoxFileEntry fileEntry = fileInfo.entries[0];

                    if (Share)
                    {
                        AllowReportProgress = false;
                        result.URL          = CreateSharedLink(fileEntry.id);
                    }
                    else
                    {
                        result.URL = string.Format("https://app.box.com/files/0/f/{0}/1/f_{1}", fileEntry.parent.id, fileEntry.id);
                    }
                }
            }

            return(result);
        }
 public void BoxListFolders(BoxFileEntry fileEntry)
 {
     if (!OAuth2Info.CheckOAuth(Config.BoxOAuth2Info))
     {
         MessageBox.Show("Authentication required.", "Box refresh folders list failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         Box box = new Box(Config.BoxOAuth2Info);
         BoxFileInfo files = box.GetFiles(fileEntry);
         if (files != null && files.entries != null && files.entries.Length > 0)
         {
             foreach (BoxFileEntry folder in files.entries.Where(x => x.type == "folder"))
             {
                 BoxAddFolder(folder);
             }
         }
     }
 }
 private void BoxAddFolder(BoxFileEntry folder)
 {
     ListViewItem lvi = new ListViewItem(folder.name);
     lvi.Tag = folder;
     lvBoxFolders.Items.Add(lvi);
 }
Esempio n. 4
0
 public BoxFileInfo GetFiles(BoxFileEntry folder)
 {
     return GetFiles(folder.id);
 }
Esempio n. 5
0
 public BoxFileInfo GetFiles(BoxFileEntry folder)
 {
     return(GetFiles(folder.id));
 }