Ejemplo 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 = SendRequestFile("https://upload.box.com/api/2.0/files/content", stream, 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, ShareAccessLevel);
                    }
                    else
                    {
                        result.URL = string.Format("https://app.box.com/files/0/f/{0}/1/f_{1}", fileEntry.parent.id, fileEntry.id);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
 public void BoxListFolders(BoxFileEntry fileEntry)
 {
     if (!OAuth2Info.CheckOAuth(Config.BoxOAuth2Info))
     {
         MessageBox.Show(Resources.UploadersConfigForm_ListFolders_Authentication_required_, Resources.UploadersConfigForm_BoxListFolders_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);
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void BoxAddFolder(BoxFileEntry folder)
 {
     ListViewItem lvi = new ListViewItem(folder.name);
     lvi.Tag = folder;
     lvBoxFolders.Items.Add(lvi);
 }
Ejemplo n.º 4
0
 public BoxFileInfo GetFiles(BoxFileEntry folder)
 {
     return(GetFiles(folder.id));
 }
Ejemplo n.º 5
0
 public BoxFileInfo GetFiles(BoxFileEntry folder)
 {
     return GetFiles(folder.id);
 }