use of com.microsoft.graph.models.DriveItem in project msgraph-sdk-java by microsoftgraph.
the class CollectionPageSerializerTests method testEntityWithCollectionOnDefaultDeserializer.
@Test
public void testEntityWithCollectionOnDefaultDeserializer() throws Exception {
final String jsonString = "{\"createdBy\":{\"application\":{\"displayName\":\"UmtPlus\",\"id\":\"4458250c\"},\"user\":{\"id\":\"c1fba35378bf924c\"}},\"createdDateTime\":\"2020-09-16T14:53:53.61Z\",\"cTag\":\"aYzpDMUZCQTM1Mzc4QkY5MjRDITIzNDkyNS4yNTc\",\"eTag\":\"aQzFGQkEzNTM3OEJGOTI0QyEyMzQ5MjUuMTE\",\"id\":\"C1FBA35378BF924C!234925\",\"lastModifiedBy\":{\"application\":{\"displayName\":\"UmtPlus\",\"id\":\"4458250c\"},\"user\":{\"id\":\"c1fba35378bf924c\"}},\"lastModifiedDateTime\":\"2020-09-16T17:42:17.847Z\",\"name\":\"Change Flat Tire.sco\",\"parentReference\":{\"driveId\":\"c1fba35378bf924c\",\"driveType\":\"personal\",\"id\":\"C1FBA35378BF924C!234867\",\"name\":\"UmtPlus\",\"path\":\"/drive/root:/UmtPlus\"},\"size\":59228,\"webUrl\":\"https://1drv.ms/u/s!AEySv3hTo_vBjqst\",\"items\":[],\"file\":{\"hashes\":{\"quickXorHash\":\"RjqF6zG7yzMKxLlRmXkKr0tK7oQ=\",\"sha1Hash\":\"A7A1DB7C7355A372E6097C5BD7DF6CF702AFA897\",\"sha256Hash\":\"97EF73D523368EE939D084F87DE22E28BD9236CC55D6A67EE69183FFC456CA08\"},\"mimeType\":\"application/octet-stream\"},\"fileSystemInfo\":{\"createdDateTime\":\"2020-09-16T14:53:53.61Z\",\"lastModifiedDateTime\":\"2020-09-16T17:42:17.846Z\"},\"reactions\":{\"commentCount\":0},\"tags\":[],\"lenses\":[],\"thumbnails\":[{\"id\":\"0\",\"large\":{\"height\":800,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=800&height=800&cropmode=none\",\"width\":800},\"medium\":{\"height\":176,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=176&height=176&cropmode=none\",\"width\":176},\"small\":{\"height\":96,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=96&height=96&cropmode=none\",\"width\":96}}]}";
final DefaultSerializer defaultSerializer = new DefaultSerializer(logger);
final DriveItem driveItem = defaultSerializer.deserializeObject(jsonString, DriveItem.class);
assertNotNull(driveItem);
assertNotNull(driveItem.thumbnails);
assertTrue(driveItem.thumbnails.getCurrentPage().size() > 0);
}
use of com.microsoft.graph.models.DriveItem in project msgraph-beta-sdk-java by microsoftgraph.
the class OneDriveTests method testLargeFileUpload.
/**
* Test large file upload.
* https://github.com/OneDrive/onedrive-sdk-csharp/blob/master/docs/chunked-uploads.md
*
* @throws IOException if the input file is not found
* @throws InterruptedException if the chunked upload fails
*/
@Test
@Disabled
public void testLargeFileUpload() throws IOException, InterruptedException {
setUp();
// Get resource file from file system
InputStream uploadFile = OneDriveTests.class.getClassLoader().getResourceAsStream("largefile10M.blob");
long fileSize = (long) uploadFile.available();
UploadSession uploadSession = testBase.graphClient.me().drive().root().itemWithPath("largefile10M.blob").createUploadSession(DriveItemCreateUploadSessionParameterSet.newBuilder().withItem(new DriveItemUploadableProperties()).build()).buildRequest().post();
LargeFileUploadTask<DriveItem> chunkedUploadProvider = new LargeFileUploadTask<DriveItem>(uploadSession, testBase.graphClient, uploadFile, fileSize, DriveItem.class);
final LargeFileUploadResult<DriveItem> result = chunkedUploadProvider.upload(0, null, callback);
assertNotNull(result);
}
use of com.microsoft.graph.models.DriveItem in project msgraph-beta-sdk-java by microsoftgraph.
the class UserTests method meDriveRoot.
@Test
public void meDriveRoot() {
// GET me/drive/root
final DriveItem driveItem = graphServiceClient.me().drive().root().buildRequest().get();
assertNotNull(driveItem);
}
use of com.microsoft.graph.models.DriveItem in project msgraph-sdk-java by microsoftgraph.
the class OneDriveTests method testLargeFileUpload.
/**
* Test large file upload.
* https://github.com/OneDrive/onedrive-sdk-csharp/blob/master/docs/chunked-uploads.md
*
* @throws IOException if the input file is not found
* @throws InterruptedException if the chunked upload fails
*/
@Test
@Disabled
public void testLargeFileUpload() throws IOException, InterruptedException {
setUp();
// Get resource file from file system
InputStream uploadFile = OneDriveTests.class.getClassLoader().getResourceAsStream("largefile10M.blob");
long fileSize = (long) uploadFile.available();
UploadSession uploadSession = testBase.graphClient.me().drive().root().itemWithPath("largefile10M.blob").createUploadSession(DriveItemCreateUploadSessionParameterSet.newBuilder().withItem(new DriveItemUploadableProperties()).build()).buildRequest().post();
LargeFileUploadTask<DriveItem> chunkedUploadProvider = new LargeFileUploadTask<DriveItem>(uploadSession, testBase.graphClient, uploadFile, fileSize, DriveItem.class);
final LargeFileUploadResult<DriveItem> result = chunkedUploadProvider.upload(0, null, callback);
assertNotNull(result);
}
use of com.microsoft.graph.models.DriveItem in project msgraph-sdk-java by microsoftgraph.
the class OneDriveTests method downloadJsonFileFromOneDrive.
@Test
@Disabled
public void downloadJsonFileFromOneDrive() throws Exception {
setUp();
final DriveItemUploadableProperties item = new DriveItemUploadableProperties();
item.name = "test.json";
item.additionalDataManager().put("@microsoft.graph.conflictBehavior", new JsonPrimitive("replace"));
final InputStream uploadFile = new ByteArrayInputStream("{\"hehe\":\"haha\"}".getBytes(StandardCharsets.UTF_8));
final long fileSize = (long) uploadFile.available();
final UploadSession session = testBase.graphClient.me().drive().root().itemWithPath(item.name).createUploadSession(DriveItemCreateUploadSessionParameterSet.newBuilder().withItem(item).build()).buildRequest().post();
LargeFileUploadTask<DriveItem> chunkedUploadProvider = new LargeFileUploadTask<DriveItem>(session, testBase.graphClient, uploadFile, fileSize, DriveItem.class);
final LargeFileUploadResult<DriveItem> result = chunkedUploadProvider.upload(0, null, callback);
assertNotNull(result);
final InputStream stream = testBase.graphClient.me().drive().root().itemWithPath(item.name).content().buildRequest().get();
final String fileContent = CoreHttpProvider.streamToString(stream);
assertTrue(fileContent.length() > 0);
}
Aggregations