public BoxUtils.FileFolderInfo GetBoxFileInfoForFileID(Guid fileID) { Guid blobHandler = GetBlobHandlerForFileID(fileID); BoxFileCache bfc = GetFileInfoFromCache(blobHandler); var tokenHandler = PXGraph.CreateInstance <UserTokenHandler>(); BoxUtils.FileFolderInfo fileInfo = BoxUtils.GetFileInfo(tokenHandler, bfc.FileID).Result; if (fileInfo == null) { throw new PXException(Messages.FileNotFoundInBox, bfc.FileID); } return(fileInfo); }
public void DeleteFileFromBox(Guid blobHandler) { var tokenHandler = PXGraph.CreateInstance <UserTokenHandler>(); BoxFileCache bfc = GetFileInfoFromCache(blobHandler); try { BoxUtils.DeleteFile(tokenHandler, bfc.FileID).Wait(); } catch (AggregateException ae) { ScreenUtils.HandleAggregateException(ae, HttpStatusCode.NotFound, (exception) => { throw new PXException(Messages.FileNotFoundInBox, bfc.FileID, exception); }); } }
public byte[] DownloadFileFromBox(Guid blobHandler) { var tokenHandler = PXGraph.CreateInstance <UserTokenHandler>(); BoxFileCache bfc = GetFileInfoFromCache(blobHandler); try { return(BoxUtils.DownloadFile(tokenHandler, bfc.FileID).Result); } catch (AggregateException ae) { ScreenUtils.HandleAggregateException(ae, HttpStatusCode.NotFound, (exception) => { throw new PXException(Messages.BoxFileNotFound, exception); }); return(new byte[0]); } }