public async System.Threading.Tasks.Task <List <DropBoxFile> > GetFilesAndFoldersInfo(string token)
        {
            List <DropBoxFile> objs = new List <DropBoxFile>();

            using (var dbx = new DropboxClient(token))
            {
                var list = await dbx.Files.ListFolderAsync(string.Empty, recursive : true);


                foreach (var item in list.Entries.Where(i => i.IsFolder))
                {
                    Console.WriteLine("D  {0}/", item.Name);
                }

                foreach (var item in list.Entries.Where(i => i.IsFile))
                {
                    Console.WriteLine("F{0,8} {1}", item.AsFile.Size, item.Name);
                    var obj = new DropBoxFile()
                    {
                        Name = item.Name, ModifiedAt = item.AsFile.ClientModified.ToString(), Size = item.AsFile.Size.ToString(), Path = item.AsFile.PathLower
                    };
                    objs.Add(obj);
                }
                return(objs);
            }
        }
 public void GetFiles_Result(RequestResult result)
 {
     if (result.StatusCode == 200)
     {
         foreach (UniValue item in result["contents"])
         {
             DropBoxFile drop = new DropBoxFile(item);
             file.Add(drop);
         }
     }
 }
Beispiel #3
0
 public async Task AddFiles(string id)
 {
     try
     {
         RequestResult result = OAuthUtility.Get("https://api.dropbox.com/1/metadata/auto/", new HttpParameterCollection {
             { "path", id }, { "access_token", driveinfo.token.access_token }, { "include_media_info", "true" }
         });
         var map = new ApiDataMapping();
         map.Add("path", "FileID");
         map.Add("path", "FileName");
         map.Add("thumb_exists", "Thumnail");
         map.Add("bytes", "FileSize", typeof(long));
         map.Add("modified", "modifiedDate");
         foreach (var item in result.CollectionItems.Items["contents"].CollectionItems.Items.Values)
         {
             FileInfo fi = new FileInfo(item, map);
             fi.driveinfo = driveinfo;
             if (id == "/")
             {
                 fi.Path = "DropBox/";
             }
             if (fi.Thumnail == "True")
             {
                 fi.Thumnail = GetTumbNail(true, fi.FileID);
             }
             else
             {
                 fi.Thumnail = GetTumbNail(false, fi.FileID);
             }
             if (item["icon"].ToString() == "folder" || item["icon"].ToString() == "folder_app")
             {
                 fi.IsFile = false;
                 fi.Path  += fi.FileID;
             }
             else
             {
                 fi.IsFile    = true;
                 fi.FileName  = GetFileName(fi.FileName);
                 fi.Extention = GetExtension(fi.FileName);
             }
             fi.DownUrl = "https://api-content.dropbox.com/1/files/auto/" + fi.FileID;
             DropBoxFile items = new DropBoxFile(fi);
             file.Add(items);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(string.Format("드롭박스 파일 불러오기 오류 : {0}", e));
     }
 }
        public async System.Threading.Tasks.Task <ActionResult> Create(DropBoxFile dropBoxFile)
        {
            try
            {
                string FileName      = dropBoxFile.Name;
                string FileExtension = Path.GetExtension(dropBoxFile.ImageFile.FileName);

                FileName = FileName.Trim() + FileExtension;
                await new DropBoxService().UploadAFile(ValueStore.token, dropBoxFile.ImageFile, FileName);
                return(RedirectToAction("Details"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #5
0
        public CloudFiles AddFiles(Dictionary <string, object> items)
        {
            UniValue files = UniValue.Create(items);
            var      map   = new ApiDataMapping();

            map.Add("path", "FileID");
            map.Add("path", "FileName");
            map.Add("thumb_exists", "Thumnail");
            map.Add("bytes", "FileSize", typeof(long));
            map.Add("modified", "modifiedDate");
            FileInfo fi = new FileInfo(files, map);

            fi.driveinfo = driveinfo;
            if (fi.Thumnail == "True")
            {
                fi.Thumnail = GetTumbNail(true, fi.FileID);
            }
            else
            {
                fi.Thumnail = GetTumbNail(false, fi.FileID);
            }
            if (items["icon"].ToString() == "folder")
            {
                fi.IsFile = false;
            }
            else
            {
                fi.IsFile    = true;
                fi.FileName  = GetFileName(fi.FileName);
                fi.Extention = GetExtension(fi.FileName);
                fi.DownUrl   = "https://api-content.dropbox.com/1/files/auto/" + fi.FileID;
            }
            DropBoxFile itemss = new DropBoxFile(fi);

            file.Add(itemss);
            return(itemss);
        }