@Test public void insertShouldReturnAppropriateItem() throws Exception { String rootId = graphClient.me().drive().root().buildRequest().get().id; byte[] testFile = new byte[] { 1, 2, 3, -2, 4, 2, 2 }; String fileName = "file.txt"; Calendar created = Calendar.getInstance(); Calendar modified = Calendar.getInstance(); DriveItem item = oneDriveAPI.insert(rootId, fileName, created, modified, new ByteArrayInputStream(testFile), "rename"); assertEquals(fileName, item.name); assertEquals(testFile.length, (long) item.size); assertEquals(rootId, item.parentReference.id); }
public DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior) throws OneDriveException { if (LOG.isDebugEnabled()) { LOG.debug("insert file"); } String updateUploadUrl = null; try { updateUploadUrl = getInsertUploadUrl(parentId, fileName, conflictBehavior); return insertUpdate(updateUploadUrl, inputStream); } catch (OneDriveException | RefreshAccessException | IOException e) { throw new OneDriveException("Error insert file parentId " + parentId + ", fileName " + fileName + ": " + e.getMessage(),e); } }
OneDriveAPI { public DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior) throws OneDriveException { if (LOG.isDebugEnabled()) { LOG.debug("insert file"); } String updateUploadUrl = null; try { updateUploadUrl = getInsertUploadUrl(parentId, fileName, conflictBehavior); return insertUpdate(updateUploadUrl, inputStream); } catch (OneDriveException | RefreshAccessException | IOException e) { throw new OneDriveException("Error insert file parentId " + parentId + ", fileName " + fileName + ": " + e.getMessage(),e); } } }
OneDriveAPI { public DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior) throws OneDriveException { if (LOG.isDebugEnabled()) { LOG.debug("insert file"); } String updateUploadUrl = null; try { updateUploadUrl = getInsertUploadUrl(parentId, fileName, conflictBehavior); return insertUpdate(updateUploadUrl, inputStream); } catch (OneDriveException | RefreshAccessException | IOException e) { throw new OneDriveException("Error insert file parentId " + parentId + ", fileName " + fileName + ": " + e.getMessage(),e); } } OneDriveAPI(String clientId, String clientSecret, String authCode, String redirectUrl);   OneDriveAPI(String clientId,
              String clientSecret,
              String accessToken,
              String refreshToken,
              long expirationTime,
              String redirectUrl); }
OneDriveAPI { public DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior) throws OneDriveException { if (LOG.isDebugEnabled()) { LOG.debug("insert file"); } String updateUploadUrl = null; try { updateUploadUrl = getInsertUploadUrl(parentId, fileName, conflictBehavior); return insertUpdate(updateUploadUrl, inputStream); } catch (OneDriveException | RefreshAccessException | IOException e) { throw new OneDriveException("Error insert file parentId " + parentId + ", fileName " + fileName + ": " + e.getMessage(),e); } } OneDriveAPI(String clientId, String clientSecret, String authCode, String redirectUrl);   OneDriveAPI(String clientId,
              String clientSecret,
              String accessToken,
              String refreshToken,
              long expirationTime,
              String redirectUrl); SharingLink createLink(String itemId, String type); void updateToken(OneDriveStoredToken newToken); void removeFolder(String fileId); void removeFile(String fileId); User getUser(); synchronized String getRootId(); synchronized String getUserId(); DriveItem createFolder(String parentId, String name, Calendar created); DriveItem copyFile(String parentId, String fileName, String fileId); DriveItem copyFolder(String parentId, String name, String folderId); OneDriveStoredToken getStoredToken(); @Deprecated String getNotificationUrl(); Subscription getSubscription(); DriveItem copy(String parentId, String fileName, String fileId, boolean isFile); IDriveItemCollectionPage getDriveItemCollectionPage(String folderId); @Deprecated List<DriveItem> getFiles(String folderId); ChangesIterator changes(String deltaToken); String getInsertUploadUrl(String parentId, String name, String conflictBehavior); DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior); DriveItem updateFileContent(String itemId, Calendar created, Calendar modified, InputStream inputStream); DeltaDriveFiles getAllFiles(); DriveItem updateFile(DriveItem driveItem); DriveItem getItem(String itemId); Drive getDrive(); String getBusinessPreviewLink(String itemId); SimpleChildIterator getSimpleChildIterator(Collection<HashSetCompatibleDriveItem> items); ChildIterator getChildIterator(String folderId); }
OneDriveAPI { public DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior) throws OneDriveException { if (LOG.isDebugEnabled()) { LOG.debug("insert file"); } String updateUploadUrl = null; try { updateUploadUrl = getInsertUploadUrl(parentId, fileName, conflictBehavior); return insertUpdate(updateUploadUrl, inputStream); } catch (OneDriveException | RefreshAccessException | IOException e) { throw new OneDriveException("Error insert file parentId " + parentId + ", fileName " + fileName + ": " + e.getMessage(),e); } } OneDriveAPI(String clientId, String clientSecret, String authCode, String redirectUrl);   OneDriveAPI(String clientId,
              String clientSecret,
              String accessToken,
              String refreshToken,
              long expirationTime,
              String redirectUrl); SharingLink createLink(String itemId, String type); void updateToken(OneDriveStoredToken newToken); void removeFolder(String fileId); void removeFile(String fileId); User getUser(); synchronized String getRootId(); synchronized String getUserId(); DriveItem createFolder(String parentId, String name, Calendar created); DriveItem copyFile(String parentId, String fileName, String fileId); DriveItem copyFolder(String parentId, String name, String folderId); OneDriveStoredToken getStoredToken(); @Deprecated String getNotificationUrl(); Subscription getSubscription(); DriveItem copy(String parentId, String fileName, String fileId, boolean isFile); IDriveItemCollectionPage getDriveItemCollectionPage(String folderId); @Deprecated List<DriveItem> getFiles(String folderId); ChangesIterator changes(String deltaToken); String getInsertUploadUrl(String parentId, String name, String conflictBehavior); DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior); DriveItem updateFileContent(String itemId, Calendar created, Calendar modified, InputStream inputStream); DeltaDriveFiles getAllFiles(); DriveItem updateFile(DriveItem driveItem); DriveItem getItem(String itemId); Drive getDrive(); String getBusinessPreviewLink(String itemId); SimpleChildIterator getSimpleChildIterator(Collection<HashSetCompatibleDriveItem> items); ChildIterator getChildIterator(String folderId); final static String SCOPES; }