public async Task<List<string>> uploadFilesAsync(List<Models.SupportClasses.UploadInfo> toUpload, CommonDescriptor folderDestination) { var _oneDriveClient = InitializeAPI.oneDriveClient; List<string> newFileIDs = new List<string>(); OneDriveCommunicationParser odcp = new OneDriveCommunicationParser(); string fileName, mimeType; foreach (Models.SupportClasses.UploadInfo ui in toUpload) { FileStream fileStream = (FileStream)ui.getFileStream(); fileName = ui.getFileName(); string fullPath = folderDestination.FilePath + "\\" + fileName; //TODO: need to remove the account name at the beginning of this string. //need file path var uploadedItem = await _oneDriveClient.Drive.Root.ItemWithPath(fullPath).Content.Request().PutAsync<Item>(fileStream); fileStream.Close(); newFileIDs.Add(uploadedItem.Id); } return newFileIDs; }
public async Task<bool> downloadFileAsync(CommonDescriptor cd) { OneDriveCommunicationParser odcp = new OneDriveCommunicationParser(); WindowsDownloadManager wdm = new WindowsDownloadManager(); var _oneDriveClient = InitializeAPI.oneDriveClient; //_oneDriveClient.AuthenticateAsync(); var fileId = cd.FileID; string extension = odcp.getExtension(cd.FileType); try { var contentStream = await _oneDriveClient.Drive.Items[fileId].Content.Request().GetAsync(); wdm.downloadFile((MemoryStream)contentStream, cd.FileName + extension); } catch (Exception e) { Console.WriteLine(e); return false; } return true; }
public void getExtensionTest() { OneDriveCommunicationParser odcp = new OneDriveCommunicationParser(); string s = odcp.getExtension("anything"); if (s != null) { Assert.Fail(); } }
public void OneDriveCommunicationParserTest() { try { OneDriveCommunicationParser odcp = new OneDriveCommunicationParser(); } catch (Exception e) { Assert.Fail(); } }
public void createCommonDescriptorTest() { OneDriveCommunicationParser odcp = new OneDriveCommunicationParser(); string json = "\"FileName\":\"Delt Calendar 2015\",\"FileType\":\"application/vnd.google-apps.spreadsheet\",\"FilePath\":\"GoogleDrive\\Delta Tau Delta - Beta Gamma\\The Delt Library\",\"FileID\":\"1Sjaiv_xT_wvuoSvjy7lQeU09QY6kQ6DLuSRciYvx9ys\",\"LastModified\":\"Date(1449039649000)\",\"FileSize\":0"; string relPath = "OneDrive"; try { var cd = odcp.createCommonDescriptor(relPath, json); } catch (Exception e) { } }
public async Task<bool> deleteFileAsync(CommonDescriptor cd) { OneDriveCommunicationParser odcp = new OneDriveCommunicationParser(); var _oneDriveClient = InitializeAPI.oneDriveClient; var fileId = cd.FileID; try { await _oneDriveClient.Drive.Items[fileId].Request().DeleteAsync(); } catch (Exception e) { Console.WriteLine(e); return false; } return true; }
public OneDriveCalls() { oneDriveCommParser = new OneDriveCommunicationParser(); }