File Upload using Box java SDK
Hi,
I am trying to upload a file from my local machine to my box developer account using Box Java SDK and developer token. But i am getting exception.I am new to box software, please help me to resolve this issue. If i am able to upload the document, i need to check the preview feature for that file. Thank you in advance.
public static void main(String[] args) throws FileNotFoundException
{
BoxAPIConnection api=new BoxAPIConnection("eAoWeATLDlBkrqSrwWPFcj5jJwRxTS8d");
BoxFolder rootFolder= BoxFolder.getRootFolder(api);
FileInputStream stream= null;
String filePath = "D:\\Sonali_files\\Box-Project";
try {
stream = new FileInputStream(filePath);
} catch (FileNotFoundException e) {
// TO DO Auto-generated catch block
e.printStackTrace();
}
String fileName = FilenameUtils.getBaseName(filePath.toString());
rootFolder.uploadFile(stream, fileName);
}
Exception:
java.io.FileNotFoundException: D:\Sonali_files\Box-Project (Access is denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:146)
at java.io.FileInputStream.(FileInputStream.java:101)
Exception in thread "main" java.lang.NullPointerException
at com.box.sdk.BoxMultipartRequest.writeBody(BoxMultipartRequest.java:141)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:407)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:227)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:202)
at com.box.sdk.BoxFolder.uploadFile(BoxFolder.java:468)
at com.box.sdk.BoxFolder.uploadFile(BoxFolder.java:415)
Please help me. Once file uploaded the file, how can i preview the document using Box java SDK. when i am referring documentation, their a getEmbedLink method which will used to get the URL link of the document. But how can i preview the document without using content preview UI element. Their is no straight away method to preview the document similar to update a file, delete a file. Please help me, i need to preview the document which i was uploaded before using my developer token.
Thanks,
sonali
Please sign in to leave a comment.
Comments
0 comments