public async Task <ActionResult> Upload(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                var fileName = file.FileName;
                using (var fs = file.InputStream)
                {
                    // Create request object with name and parent folder the file should be uploaded to
                    BoxFileRequest request = new BoxFileRequest()
                    {
                        Name   = fileName,
                        Parent = new BoxRequestEntity()
                        {
                            Id = "0"
                        }
                    };
                    string email   = this.GetCurrentUserEmail();
                    var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

                    var boxFile = await BoxHelper.UserClient(boxUser.Id).FilesManager.UploadAsync(request, fs);
                }
            }

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public async Task <ActionResult> Doc(string id)
        {
            var file = await BoxHelper.UserClient().FilesManager.GetInformationAsync(id);

            ViewBag.BoxFile = file;

            return(View());
        }
        public async Task <ActionResult> Preview(string id)
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var previewUrl = await BoxHelper.UserClient(boxUser.Id).FilesManager.GetPreviewLinkAsync(id);

            return(Redirect(previewUrl.ToString()));
        }
        public async Task <FileStreamResult> Thumbnail(string id)
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var thumbBytes = await BoxHelper.UserClient(boxUser.Id).FilesManager.GetThumbnailAsync(id, minHeight: 256, minWidth: 256, maxHeight: 256, maxWidth: 256);

            return(new FileStreamResult(thumbBytes, "image/png"));
        }
        public async Task <ActionResult> Download(string id)
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var downloadUrl = await BoxHelper.UserClient(boxUser.Id).FilesManager.GetDownloadUriAsync(id);

            return(Redirect(downloadUrl.ToString()));
        }
        public async Task <ActionResult> Setup()
        {
            string  email = this.GetCurrentUserEmail();
            BoxUser user  = await BoxHelper.CreateBoxUser(email);

            BoxClient userClient = BoxHelper.UserClient(user.Id);
            await BoxHelper.Setup(userClient);

            return(RedirectToAction("index", "home"));
        }
Exemple #7
0
        // GET: App
        public async Task <ActionResult> Index()
        {
            var items = await BoxHelper.UserClient().FoldersManager.GetFolderItemsAsync("0", 100);

            ViewBag.Folders = items.Entries.Where(item => item.Type == "folder");
            ViewBag.Files   = items.Entries.Where(item => item.Type == "file");

            ViewBag.AccessToken = BoxHelper.UserToken();

            return(View());
        }
        public async Task <ActionResult> Doc(string id)
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var file = await BoxHelper.UserClient(boxUser.Id).FilesManager.GetInformationAsync(id);

            ViewBag.BoxFile = file;

            return(View());
        }
        // GET: App
        public async Task <ActionResult> Index()
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var items = await BoxHelper.UserClient(boxUser.Id).FoldersManager.GetFolderItemsAsync("0", 100);

            ViewBag.Folders = items.Entries.Where(item => item.Type == "folder");
            ViewBag.Files   = items.Entries.Where(item => item.Type == "file");

            ViewBag.AccessToken = BoxHelper.UserToken(boxUser.Id);

            return(View());
        }
Exemple #10
0
        public async Task <ActionResult> Preview(string id)
        {
            var previewUrl = await BoxHelper.UserClient().FilesManager.GetPreviewLinkAsync(id);

            return(Redirect(previewUrl.ToString()));
        }
Exemple #11
0
        public async Task <FileStreamResult> Thumbnail(string id)
        {
            var thumbBytes = await BoxHelper.UserClient().FilesManager.GetThumbnailAsync(id, minHeight: 256, minWidth: 256, maxHeight: 256, maxWidth: 256);

            return(new FileStreamResult(thumbBytes, "image/png"));
        }
Exemple #12
0
        public async Task <ActionResult> Download(string id)
        {
            var downloadUrl = await BoxHelper.UserClient().FilesManager.GetDownloadUriAsync(id);

            return(Redirect(downloadUrl.ToString()));
        }