public string FileRename(File <string> file, string newTitle) { var driveFile = GetDriveEntry(file.ID); driveFile.Name = newTitle; driveFile = ProviderInfo.Storage.RenameEntry(driveFile.Id, driveFile.Name); ProviderInfo.CacheReset(driveFile); var parentDriveId = GetParentDriveId(driveFile); if (parentDriveId != null) { ProviderInfo.CacheReset(parentDriveId, false); } return(MakeId(driveFile.Id)); }
public string FileRename(File <string> file, string newTitle) { var onedriveFile = GetOneDriveItem(file.ID); newTitle = GetAvailableTitle(newTitle, GetParentFolderId(onedriveFile), IsExist); onedriveFile = ProviderInfo.Storage.RenameItem(onedriveFile.Id, newTitle); ProviderInfo.CacheReset(onedriveFile.Id); var parentId = GetParentFolderId(onedriveFile); if (parentId != null) { ProviderInfo.CacheReset(parentId); } return(MakeId(onedriveFile.Id)); }
public File <string> SaveFile(File <string> file, Stream fileStream) { if (file == null) { throw new ArgumentNullException("file"); } if (fileStream == null) { throw new ArgumentNullException("fileStream"); } Item newOneDriveFile = null; if (file.ID != null) { newOneDriveFile = ProviderInfo.Storage.SaveStream(MakeOneDriveId(file.ID), fileStream); if (!newOneDriveFile.Name.Equals(file.Title)) { file.Title = GetAvailableTitle(file.Title, GetParentFolderId(newOneDriveFile), IsExist); newOneDriveFile = ProviderInfo.Storage.RenameItem(newOneDriveFile.Id, file.Title); } } else if (file.FolderID != null) { var folderId = MakeOneDriveId(file.FolderID); var folder = GetOneDriveItem(folderId); file.Title = GetAvailableTitle(file.Title, folderId, IsExist); newOneDriveFile = ProviderInfo.Storage.CreateFile(fileStream, file.Title, MakeOneDrivePath(folder)); } if (newOneDriveFile != null) { ProviderInfo.CacheReset(newOneDriveFile.Id); } var parentId = GetParentFolderId(newOneDriveFile); if (parentId != null) { ProviderInfo.CacheReset(parentId); } return(ToFile(newOneDriveFile)); }
public string FileRename(File <string> file, string newTitle) { var dropboxFile = GetDropboxFile(file.ID); var parentFolderPath = GetParentFolderPath(dropboxFile); newTitle = GetAvailableTitle(newTitle, parentFolderPath, IsExist); dropboxFile = ProviderInfo.Storage.MoveFile(MakeDropboxPath(dropboxFile), parentFolderPath, newTitle); ProviderInfo.CacheReset(dropboxFile); var parentPath = GetParentFolderPath(dropboxFile); if (parentPath != null) { ProviderInfo.CacheReset(parentPath); } return(MakeId(dropboxFile)); }
private File <string> FinalizeUploadSession(ChunkedUploadSession <string> uploadSession) { if (uploadSession.Items.ContainsKey("OneDriveSession")) { var oneDriveSession = uploadSession.GetItemOrDefault <ResumableUploadSession>("OneDriveSession"); ProviderInfo.CacheReset(oneDriveSession.FileId); var parentDriveId = oneDriveSession.FolderId; if (parentDriveId != null) { ProviderInfo.CacheReset(parentDriveId); } return(ToFile(GetOneDriveItem(oneDriveSession.FileId))); } using var fs = new FileStream(uploadSession.GetItemOrDefault <string>("TempPath"), FileMode.Open, FileAccess.Read, System.IO.FileShare.None, 4096, FileOptions.DeleteOnClose); return(SaveFile(uploadSession.File, fs)); }
public File <string> SaveFile(File <string> file, Stream fileStream) { if (file == null) { throw new ArgumentNullException("file"); } if (fileStream == null) { throw new ArgumentNullException("fileStream"); } BoxFile newBoxFile = null; if (file.ID != null) { var fileId = MakeBoxId(file.ID); newBoxFile = ProviderInfo.Storage.SaveStream(fileId, fileStream); if (!newBoxFile.Name.Equals(file.Title)) { var folderId = GetParentFolderId(GetBoxFile(fileId)); file.Title = GetAvailableTitle(file.Title, folderId, IsExist); newBoxFile = ProviderInfo.Storage.RenameFile(fileId, file.Title); } } else if (file.FolderID != null) { var folderId = MakeBoxId(file.FolderID); file.Title = GetAvailableTitle(file.Title, folderId, IsExist); newBoxFile = ProviderInfo.Storage.CreateFile(fileStream, file.Title, folderId); } ProviderInfo.CacheReset(newBoxFile); var parentId = GetParentFolderId(newBoxFile); if (parentId != null) { ProviderInfo.CacheReset(parentId); } return(ToFile(newBoxFile)); }
public File <string> SaveFile(File <string> file, Stream fileStream) { if (file == null) { throw new ArgumentNullException("file"); } if (fileStream == null) { throw new ArgumentNullException("fileStream"); } FileMetadata newDropboxFile = null; if (file.ID != null) { var filePath = MakeDropboxPath(file.ID); newDropboxFile = ProviderInfo.Storage.SaveStream(filePath, fileStream); if (!newDropboxFile.Name.Equals(file.Title)) { var parentFolderPath = GetParentFolderPath(newDropboxFile); file.Title = GetAvailableTitle(file.Title, parentFolderPath, IsExist); newDropboxFile = ProviderInfo.Storage.MoveFile(filePath, parentFolderPath, file.Title); } } else if (file.FolderID != null) { var folderPath = MakeDropboxPath(file.FolderID); file.Title = GetAvailableTitle(file.Title, folderPath, IsExist); newDropboxFile = ProviderInfo.Storage.CreateFile(fileStream, file.Title, folderPath); } ProviderInfo.CacheReset(newDropboxFile); var parentPath = GetParentFolderPath(newDropboxFile); if (parentPath != null) { ProviderInfo.CacheReset(parentPath); } return(ToFile(newDropboxFile)); }
public Stream GetFileStream(File <string> file, long offset) { var dropboxFilePath = MakeDropboxPath(file.ID); ProviderInfo.CacheReset(dropboxFilePath, true); var dropboxFile = GetDropboxFile(file.ID); if (dropboxFile == null) { throw new ArgumentNullException("file", FilesCommonResource.ErrorMassage_FileNotFound); } if (dropboxFile is ErrorFile errorFile) { throw new Exception(errorFile.Error); } var fileStream = ProviderInfo.Storage.DownloadStream(MakeDropboxPath(dropboxFile), (int)offset); return(fileStream); }
public Stream GetFileStream(File <string> file, long offset) { var boxFileId = MakeBoxId(file.ID); ProviderInfo.CacheReset(boxFileId, true); var boxFile = GetBoxFile(file.ID); if (boxFile == null) { throw new ArgumentNullException("file", FilesCommonResource.ErrorMassage_FileNotFound); } if (boxFile is ErrorFile) { throw new Exception(((ErrorFile)boxFile).Error); } var fileStream = ProviderInfo.Storage.DownloadStream(boxFile, (int)offset); return(fileStream); }
public Stream GetFileStream(File <string> file, long offset) { var onedriveFileId = MakeOneDriveId(file.ID); ProviderInfo.CacheReset(onedriveFileId); var onedriveFile = GetOneDriveItem(file.ID); if (onedriveFile == null) { throw new ArgumentNullException("file", FilesCommonResource.ErrorMassage_FileNotFound); } if (onedriveFile is ErrorItem errorItem) { throw new Exception(errorItem.Error); } var fileStream = ProviderInfo.Storage.DownloadStream(onedriveFile, (int)offset); return(fileStream); }
public File <string> CopyFile(string fileId, string toFolderId) { var dropboxFile = GetDropboxFile(fileId); if (dropboxFile is ErrorFile errorFile) { throw new Exception(errorFile.Error); } var toDropboxFolder = GetDropboxFolder(toFolderId); if (toDropboxFolder is ErrorFolder errorFolder) { throw new Exception(errorFolder.Error); } var newDropboxFile = ProviderInfo.Storage.CopyFile(MakeDropboxPath(dropboxFile), MakeDropboxPath(toDropboxFolder), dropboxFile.Name); ProviderInfo.CacheReset(newDropboxFile); ProviderInfo.CacheReset(MakeDropboxPath(toDropboxFolder)); return(ToFile(newDropboxFile)); }
public File <string> CopyFile(string fileId, string toFolderId) { var driveFile = GetDriveEntry(fileId); if (driveFile is ErrorDriveEntry) { throw new Exception(((ErrorDriveEntry)driveFile).Error); } var toDriveFolder = GetDriveEntry(toFolderId); if (toDriveFolder is ErrorDriveEntry) { throw new Exception(((ErrorDriveEntry)toDriveFolder).Error); } var newDriveFile = ProviderInfo.Storage.CopyEntry(toDriveFolder.Id, driveFile.Id); ProviderInfo.CacheReset(newDriveFile); ProviderInfo.CacheReset(toDriveFolder.Id, false); return(ToFile(newDriveFile)); }
public Folder <string> CopyFolder(string folderId, string toFolderId, CancellationToken?cancellationToken) { var dropboxFolder = GetDropboxFolder(folderId); if (dropboxFolder is ErrorFolder) { throw new Exception(((ErrorFolder)dropboxFolder).Error); } var toDropboxFolder = GetDropboxFolder(toFolderId); if (toDropboxFolder is ErrorFolder) { throw new Exception(((ErrorFolder)toDropboxFolder).Error); } var newDropboxFolder = ProviderInfo.Storage.CopyFolder(MakeDropboxPath(dropboxFolder), MakeDropboxPath(toDropboxFolder), dropboxFolder.Name); ProviderInfo.CacheReset(newDropboxFolder); ProviderInfo.CacheReset(MakeDropboxPath(newDropboxFolder), false); ProviderInfo.CacheReset(MakeDropboxPath(toDropboxFolder)); return(ToFolder(newDropboxFolder)); }
public File <string> CopyFile(string fileId, string toFolderId) { var onedriveFile = GetOneDriveItem(fileId); if (onedriveFile is ErrorItem errorItem) { throw new Exception(errorItem.Error); } var toOneDriveFolder = GetOneDriveItem(toFolderId); if (toOneDriveFolder is ErrorItem errorItem1) { throw new Exception(errorItem1.Error); } var newTitle = GetAvailableTitle(onedriveFile.Name, toOneDriveFolder.Id, IsExist); var newOneDriveFile = ProviderInfo.Storage.CopyItem(onedriveFile.Id, newTitle, toOneDriveFolder.Id); ProviderInfo.CacheReset(newOneDriveFile.Id); ProviderInfo.CacheReset(toOneDriveFolder.Id); return(ToFile(newOneDriveFile)); }
public Folder <string> CopyFolder(string folderId, string toFolderId, CancellationToken?cancellationToken) { var driveFolder = GetDriveEntry(folderId); if (driveFolder is ErrorDriveEntry errorDriveEntry) { throw new Exception(errorDriveEntry.Error); } var toDriveFolder = GetDriveEntry(toFolderId); if (toDriveFolder is ErrorDriveEntry errorDriveEntry1) { throw new Exception(errorDriveEntry1.Error); } var newDriveFolder = ProviderInfo.Storage.InsertEntry(null, driveFolder.Name, toDriveFolder.Id, true); ProviderInfo.CacheReset(newDriveFolder); ProviderInfo.CacheReset(toDriveFolder.Id, true); ProviderInfo.CacheReset(toDriveFolder.Id); return(ToFolder(newDriveFolder)); }
public File <string> CopyFile(string fileId, string toFolderId) { var boxFile = GetBoxFile(fileId); if (boxFile is ErrorFile) { throw new Exception(((ErrorFile)boxFile).Error); } var toBoxFolder = GetBoxFolder(toFolderId); if (toBoxFolder is ErrorFolder) { throw new Exception(((ErrorFolder)toBoxFolder).Error); } var newTitle = GetAvailableTitle(boxFile.Name, toBoxFolder.Id, IsExist); var newBoxFile = ProviderInfo.Storage.CopyFile(boxFile.Id, newTitle, toBoxFolder.Id); ProviderInfo.CacheReset(newBoxFile); ProviderInfo.CacheReset(toBoxFolder.Id); return(ToFile(newBoxFile)); }
public Folder <string> CopyFolder(string folderId, string toFolderId, CancellationToken?cancellationToken) { var onedriveFolder = GetOneDriveItem(folderId); if (onedriveFolder is ErrorItem errorItem) { throw new Exception(errorItem.Error); } var toOneDriveFolder = GetOneDriveItem(toFolderId); if (toOneDriveFolder is ErrorItem errorItem1) { throw new Exception(errorItem1.Error); } var newTitle = GetAvailableTitle(onedriveFolder.Name, toOneDriveFolder.Id, IsExist); var newOneDriveFolder = ProviderInfo.Storage.CopyItem(onedriveFolder.Id, newTitle, toOneDriveFolder.Id); ProviderInfo.CacheReset(newOneDriveFolder.Id); ProviderInfo.CacheReset(toOneDriveFolder.Id); return(ToFolder(newOneDriveFolder)); }