Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
a954994
Fixed #325
Oct 19, 2016
1d13ec6
Fixed CheckStyle errors
Oct 19, 2016
8a16859
Added a getter + setter for the new property
Oct 19, 2016
a5ca6b0
Added a verification test
Oct 19, 2016
3bdab34
Added method BoxMultipartRequest.setContentSHA1
Oct 20, 2016
e64091a
Added SHA1 parameter to BoxFile.uploadVersion variants
Oct 20, 2016
bd58270
paging and fields support implementation, tests and javadocs for grou…
gleb-urvanov Oct 25, 2016
6d3b05a
update group feature implemented
gleb-urvanov Nov 14, 2016
0b354f9
get all metadata on file feature implementation and testing
gleb-urvanov Nov 11, 2016
da6dd1a
get all metadata on folder feature implementation
gleb-urvanov Nov 14, 2016
7fd5681
watermarking features implemented, tested, docimented
gleb-urvanov Nov 16, 2016
f0b453f
fixes and tests for tasks
gleb-urvanov Nov 16, 2016
7275777
Adding isWatermarked to BoxItem.
dmaynard Nov 17, 2016
b3033db
Moving is_watermarked from BoxItem to BoxFile and BoxFolder
dmaynard Nov 17, 2016
009a033
Moving "watermark_info" fromBoxIyem ALL_FIELDS to BoxFile and BoxFolder
dmaynard Nov 18, 2016
ae57191
removing extraneous blank lines from BoxItem.java
dmaynard Nov 18, 2016
f063d3d
Removing trailing whitespace from BoxItem.java #375
dmaynard Nov 18, 2016
4a4223d
Changed type of getIsWatermarked from Boolean to boolean
dmaynard Nov 18, 2016
9720ab1
unit tests for BoxWeblink methods
gleb-urvanov Oct 25, 2016
e10b2e3
webhooks tested and documented
gleb-urvanov Nov 11, 2016
119264d
get metadata template and get enterprise metadata features implementa…
gleb-urvanov Nov 14, 2016
b2aac57
legal holds assignments and file version legal holds features impleme…
gleb-urvanov Nov 18, 2016
4e6ed92
excess method removed, readme updated
gleb-urvanov Nov 18, 2016
059cd28
invite user feature documented
gleb-urvanov Nov 2, 2016
b874710
fixed and tests for delete and promote file version
gleb-urvanov Nov 18, 2016
57cdfa2
unit tests for BoxUser methods
gleb-urvanov Nov 18, 2016
d14b7ce
Merge pull request #371 from box/add_watermark_info
dmaynard Nov 29, 2016
534bb40
Merge pull request #342 from hotovo/feature/watermark
dmaynard Nov 30, 2016
3a0953e
Merge branch 'feature/webhook_tests' of git://github.com/hotovo/box-j…
dmaynard Nov 30, 2016
a65fad3
Merge branch 'hotovo-feature/webhook_tests'
dmaynard Nov 30, 2016
63fff9a
Merge branch 'feature/weblink' of git://github.com/hotovo/box-java-sd…
dmaynard Dec 1, 2016
add5aeb
Changed continuation indent fro 8 to 4. Whitespace change only
dmaynard Dec 1, 2016
4515432
Merge pull request #376 from box/hotovo-feature/weblink
dmaynard Dec 1, 2016
8535850
Merge pull request #374 from hotovo/feature/versions_tests
dmaynard Dec 2, 2016
458e56c
Merge pull request #375 from hotovo/feature/users_tests
dmaynard Dec 2, 2016
cf809e3
Merge branch 'feature/get_all_metadata' of git://github.com/hotovo/bo…
dmaynard Dec 6, 2016
4f54dd2
Merge branch 'hotovo-feature/get_all_metadata'
dmaynard Dec 6, 2016
dfefae8
Merge branch 'feature/get_all_metadata_on_folder' of git://github.com…
dmaynard Dec 6, 2016
a26d9b7
Merge branch 'hotovo-feature/get_all_metadata_on_folder'
dmaynard Dec 6, 2016
3c08b9c
Merge branch 'feature/update_group' of git://github.com/hotovo/box-ja…
dmaynard Dec 7, 2016
943e420
Fixed warning for missing @return javadoc in Boxuser.java
dmaynard Dec 7, 2016
7ccf518
Merge pull request #377 from box/feature/update_group
dmaynard Dec 7, 2016
bf6dd72
Adding sourceCompatibility = 1.6 and targetCompatibility = 1.6to grad…
dmaynard Dec 8, 2016
757b384
Fixing merge conflict in doc/retention_policies.md
dmaynard Dec 8, 2016
4f7aef4
Merge branch 'feature/legal_hold_advanced' of git://github.com/hotovo…
dmaynard Dec 8, 2016
f9de883
Refactored BoxLegalHold to be BoxLegalHoldPolicy to match api documents
dmaynard Dec 8, 2016
0f6e888
Updated Object name form BoxLegalHold to BoLegalHoldPolicy in ReadMe
dmaynard Dec 13, 2016
0ace5ee
Removing Java 1.6 Source Compatibility Check (it seems to break Travis)
dmaynard Dec 13, 2016
e66ded7
Adding sourceCompatibility = 1.6 back in gradle.build
dmaynard Dec 13, 2016
7211959
Merge pull request #378 from box/hotovo-feature/legal_hold_advanced
dmaynard Dec 13, 2016
f25cb99
Merge pull request #373 from hotovo/feature/invite_user_markdown
dmaynard Dec 13, 2016
dfa6208
Merge branch 'feature/get_enterprise_metadata' of git://github.com/ho…
dmaynard Dec 13, 2016
516fe64
Merge branch 'hotovo-feature/get_enterprise_metadata'
dmaynard Dec 13, 2016
4e406a9
Merge branch 'hotovo-feature/tasks_tests'
dmaynard Dec 14, 2016
27b3be8
Merge branch 'feature/groups' of git://github.com/hotovo/box-java-sdk…
dmaynard Dec 14, 2016
526d700
Merge branch 'hotovo-feature/groups'
dmaynard Dec 14, 2016
6de99c4
Merge branch 'fix-328' of git://github.com/dorfire/box-java-sdk into …
dmaynard Dec 21, 2016
958b2ff
Fix bug in passing SHA1 in uploadVersion
dmaynard Dec 21, 2016
e1d2b43
Merge branch 'dorfire-fix-328'
dmaynard Dec 21, 2016
6afc98c
Merge branch 'fix-325' of git://github.com/dorfire/box-java-sdk into …
dmaynard Dec 21, 2016
c193301
Merge branch 'dorfire-fix-325'
dmaynard Dec 21, 2016
5204b04
Updated version to 3.0.0-SNAPSHOT
dmaynard Dec 21, 2016
e037647
Changing version to 2.2.3-SNAPSHOT (trying to fix sonatype error)
dmaynard Dec 21, 2016
41c4763
Updating Version # to 2.3.0
dmaynard Jan 5, 2017
09ce2f9
Updating version number in the UserAgent.
dmaynard Jan 11, 2017
67dd31f
Adding event type CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION
dmaynard Feb 10, 2017
3d11d83
Merge pull request #391 from box/workflow-events
gcurtis Feb 13, 2017
9e5a5ad
Some changes to enable getting log output from Integration Tests
dmaynard Jan 27, 2017
0a43984
Changes to improve Integration Tests
dmaynard Feb 9, 2017
cfbb4ed
Added a new IntegrationTest type for JWT tests
dmaynard Feb 10, 2017
3be6d5f
Merge pull request #385 from box/enableTestLogging
gcurtis Feb 13, 2017
1e596fb
Create and update operations are added to Metadata Template
Feb 21, 2017
d1f763e
Javadoc fixes
Feb 22, 2017
6f98eb5
Javadoc fixes
Feb 22, 2017
cec7b1f
breaking a long line in to two
Feb 22, 2017
e921f84
breaking a long line in to two
Feb 22, 2017
08252d5
409 error handling
Feb 22, 2017
3a42fb5
Removing System.out.println
Feb 22, 2017
0c63e33
update metadatatemplate test fix
Feb 22, 2017
ac1cc92
Merge pull request #396 from box/Metadata_API_updates
dmaynard Feb 22, 2017
e0c2283
Inital check-in for supercharged file upload create session implement…
Feb 23, 2017
147345c
Abort session implementation
Feb 23, 2017
054cb01
Added getAllMetadata Integration Test Upped version to 2.3.1-SNAPSHOT
dmaynard Feb 23, 2017
3493c8c
Updated version number to 2.4.0 since we have a new createMetadata en…
dmaynard Feb 23, 2017
1751041
First attempt at generalising FileUploadSession
Feb 24, 2017
7dcb943
Upload implementation changes & code refactoring to match existing co…
Feb 27, 2017
d0e0b1a
Upload session list parts and commit are added
Feb 27, 2017
0f374d0
Upload session list parts and commit are added
Feb 27, 2017
088ff52
Commit operation returning BoxFile
Feb 27, 2017
1dfc569
Merge pull request #397 from box/getAllMetadata
dmaynard Feb 27, 2017
94e3bac
If-Match and If-None-Match headers implementation
Feb 27, 2017
ed0ecab
If-Match and If-None-Match headers implementation
Feb 27, 2017
515d9fe
Fix event stream to handle no events in the stream
dmaynard Feb 28, 2017
8272cb8
Fix checkstyle whitespace issues
dmaynard Feb 28, 2017
21d860b
Integration tests for the commit
Mar 1, 2017
06d545f
public api support for upload file is moved to 2.0 from 2.1
Mar 1, 2017
9196b0a
upload large file method is added
Mar 1, 2017
b91fc4e
upload part takes stream as input
Mar 1, 2017
10283ac
Checkstyle clean up
Mar 2, 2017
c32f37a
Upload part signature change and 202 response code fix
Mar 2, 2017
6e839c9
Added Javadoc
Mar 2, 2017
0273dba
coding style changes
Mar 2, 2017
faf746b
BoxFile.Info variable added in files.md
Mar 3, 2017
8921da7
getAuthorizationURL implementation
Mar 6, 2017
1583029
Scopes are delimited by spaces
Mar 6, 2017
7a75bcf
Files examples updates
Mar 7, 2017
0eddc39
large file upload test file input modified
Mar 7, 2017
6a3ed56
1st cut at single file collab. adds to Box file
dmaynard Mar 7, 2017
91b0b62
list parts marker fix
Mar 8, 2017
fbd6518
Abort flow implementation
Mar 8, 2017
506de44
Encoding utf-8 is enabled for the build
Mar 9, 2017
989435a
Merge pull request #400 from box/windows_build_encoding
KarthikShanmugasundaram Mar 10, 2017
ce816e9
Adding Single file Collabs and Integration tests fixes for FolderCollabs
dmaynard Mar 14, 2017
327004a
Fixing checkstyle issues in tests
dmaynard Mar 15, 2017
77a201c
Merge pull request #399 from box/master
dmaynard Mar 16, 2017
600baea
Fixed bug in singleFIleCollabTest and premature disconect in Folder R…
dmaynard Mar 20, 2017
0e2d3aa
Fix chaeckstyle whitespace issue.
dmaynard Mar 21, 2017
22ecdba
Removing extraneous blank lines
dmaynard Mar 21, 2017
a1c955c
Merge pull request #402 from box/singlefilecollab
dmaynard Mar 21, 2017
8b50a09
Inital check-in for supercharged file upload create session implement…
Feb 23, 2017
43c935b
Abort session implementation
Feb 23, 2017
98bc132
First attempt at generalising FileUploadSession
Feb 24, 2017
f6a4d1a
Upload implementation changes & code refactoring to match existing co…
Feb 27, 2017
29940b4
Upload session list parts and commit are added
Feb 27, 2017
692868b
Upload session list parts and commit are added
Feb 27, 2017
042b49e
Commit operation returning BoxFile
Feb 27, 2017
482d4c6
If-Match and If-None-Match headers implementation
Feb 27, 2017
29a3f8f
If-Match and If-None-Match headers implementation
Feb 27, 2017
76206aa
Integration tests for the commit
Mar 1, 2017
3a8b3ee
public api support for upload file is moved to 2.0 from 2.1
Mar 1, 2017
93582fa
upload large file method is added
Mar 1, 2017
51885a0
upload part takes stream as input
Mar 1, 2017
8de7f8d
Checkstyle clean up
Mar 2, 2017
479d263
Upload part signature change and 202 response code fix
Mar 2, 2017
572db0e
Added Javadoc
Mar 2, 2017
fee47f5
coding style changes
Mar 2, 2017
c6e7c04
BoxFile.Info variable added in files.md
Mar 3, 2017
2af99ce
getAuthorizationURL implementation
Mar 6, 2017
36ccad7
Scopes are delimited by spaces
Mar 6, 2017
df522d6
Files examples updates
Mar 7, 2017
97f8f8c
large file upload test file input modified
Mar 7, 2017
4765b1c
list parts marker fix
Mar 8, 2017
6275227
Abort flow implementation
Mar 8, 2017
f3d9ff7
Merge branch 'supercharged_uploads' of https://github.com/box/box-jav…
Mar 27, 2017
5e6dff6
Merge branch 'master' into supercharged_uploads
KarthikShanmugasundaram Mar 27, 2017
987b7d2
Update BoxFile.java
KarthikShanmugasundaram Mar 27, 2017
cb9d7f4
Merge pull request #407 from box/supercharged_uploads
KarthikShanmugasundaram Mar 27, 2017
943fd47
notify and canViewPath parameters are added
Mar 28, 2017
b66d00d
Merge pull request #408 from box/collaboration_notify
dmaynard Mar 28, 2017
39dce32
upload session url change
Mar 29, 2017
00eb305
Merge pull request #410 from box/upload_session_url
dmaynard Mar 29, 2017
5f155ef
support user events in event log, minor bug fixes for enterprise log …
debussyman Nov 28, 2016
b9b8c44
add auth refres into api request handling
debussyman Nov 30, 2016
d44ae1f
user event log do not take a types parameter
debussyman Dec 23, 2016
8d2827f
Adds a BoxAPIConnectionListener method for determining whether a BoxA…
debussyman Mar 8, 2017
d9dc6e6
Don't acquire the refresh lock if can't refresh, and don't raise exce…
debussyman Mar 9, 2017
aeb6191
canRefresh() happens to be called in a lot of situations, and is not …
debussyman Mar 10, 2017
25f2935
Merge branch 'master' of github.com:Docurated/box-java-sdk
AndrewCEmil Apr 14, 2017
36106b8
Support for new box event
AndrewCEmil Apr 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
gradle/
gradlew
gradlew.bat
.gradle/
gradle.properties
build/
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ You can find guides and tutorials in the `doc` directory.
* [Devices](doc/devices.md)
* [Retention Policies](doc/retention_policies.md)
* [Legal Holds Policy](doc/legal_holds.md)
* [Watermarking](doc/watermarking.md)
* [Webhooks](doc/webhooks.md)
* [Web Links](doc/weblinks.md)
* [Metadata Templates](doc/metadata_template.md)


Javadocs are generated when `gradle javadoc` is run and can be found in
`build/doc/javadoc`.
Expand Down
34 changes: 32 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sourceCompatibility = 1.6

group = 'com.box'
archivesBaseName = 'box-java-sdk'
version = '2.2.2-SNAPSHOT'
version = '2.4.0-SNAPSHOT'

repositories {
mavenCentral()
Expand All @@ -28,6 +28,11 @@ dependencies {
testCompile 'org.slf4j:slf4j-nop:1.7.7'
}

compileJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}

javadoc {
options.windowTitle 'Box Java SDK'
options.noQualifiers 'all'
Expand All @@ -37,6 +42,7 @@ javadoc {
options.noHelp true
options.noDeprecatedList true
options.noNavBar true
options.encoding 'utf-8'
options.docEncoding 'utf-8'
options.charSet 'utf-8'
options.linkSource true
Expand Down Expand Up @@ -83,12 +89,34 @@ task sourcesJar(type: Jar) {
task integrationTest(type: Test) {
description 'Runs the integration tests.'
group 'Verification'

testLogging.showStandardStreams = true
useJUnit {
includeCategories 'com.box.sdk.IntegrationTest'

}
}

task integrationTestDebug(type: Test) {
description 'Runs the integration tests.'
group 'Verification'
testLogging.showStandardStreams = true
useJUnit {
includeCategories 'com.box.sdk.IntegrationTestDebug'

}
}

task integrationTestJWT(type: Test) {
description 'Runs the JWT based integration tests.'
group 'Verification'
testLogging.showStandardStreams = true
useJUnit {
includeCategories 'com.box.sdk.IntegrationTestJWT'

}
}


jacocoTestReport.dependsOn(integrationTest);

tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -119,6 +147,8 @@ artifacts {
test {
useJUnit {
excludeCategories 'com.box.sdk.IntegrationTest'
excludeCategories 'com.box.sdk.IntegrationTestDebug'
excludeCategories 'com.box.sdk.IntegrationTestJWT'
}
}

Expand Down
4 changes: 3 additions & 1 deletion config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<suppress checks="AvoidStarImport|VisibilityModifier|Javadoc.*"
files="test.*\.java"/>
<suppress checks="JavadocType|JavadocMethod"
files="example.*\.java"/>
files="example.*\.java"/>
<suppress checks="ImportOrder"
files="test.*\.java"/>
</suppressions>
248 changes: 246 additions & 2 deletions doc/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ file's contents, upload new versions, and perform other common file operations
* [Get Metadata](#get-metadata)
* [Update Metadata](#update-metadata)
* [Delete Metadata](#delete-metadata)
* [Get All Metadata on File](#get-all-metadata-on-file)

Get a File's Information
------------------------
Expand Down Expand Up @@ -110,7 +111,7 @@ Files are uploaded to a folder by calling the
```java
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
FileInputStream stream = new FileInputStream("My File.txt");
rootFolder.uploadFile(stream, "My File.txt");
BoxFile.Info newFileInfo = rootFolder.uploadFile(stream, "My File.txt");
stream.close();
```

Expand All @@ -122,7 +123,7 @@ Upload progress can be tracked by providing the size of the file and a
```java
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
FileInputStream stream = new FileInputStream("My File.txt");
rootFolder.uploadFile(stream, "My File.txt", 1024, new ProgressListener() {
BoxFile.Info newFileInfo = rootFolder.uploadFile(stream, "My File.txt", 1024, new ProgressListener() {
public void onProgressChanged(long numBytes, long totalBytes) {
double percentComplete = numBytes / totalBytes;
}
Expand All @@ -133,6 +134,119 @@ stream.close();
[upload]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFolder.html#uploadFile(java.io.InputStream,%20java.lang.String)
[upload2]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFolder.html#uploadFile(java.io.InputStream,%20java.lang.String,%20long,%20com.box.sdk.ProgressListener)

Upload a large File in chunks
--------------------------------------

An upload session can be created with the [`createUploadSession(fileName, fileSize)`][create-upload-session] method to
upload a large file in chunks.

```java
//Create the upload session
BoxFile file = new BoxFile(api, "id");
BoxFileUploadSession.Info sessionInfo = file.createUploadSession("My_Large_File.txt", fileSize);

//Get the session resource from the session info
BoxFileUploadSession session = sessionInfo.getResource();

//Create the Message Digest for the whole file
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA1");
} catch (NoSuchAlgorithmException ae) {
throw new BoxAPIException("Digest algorithm not found", ae);
}
```
Once the upload session is created, using that session the large file can be uploaded in chuncks with the
[`uploadPart(partId, stream, offset, partSize, totalSizeOfFile)`][upload-part] method of the session instance.
If there is a failure in uploading any of the parts,
the failed part can be uploaded again without affecting the other parts.

```java
//Reading a large file
FileInputStream fis = new FileInputStream("My_Large_File.txt");
//Create the digest input stream to calculate the digest for the whole file.
DigestInputStream dis = new DigestInputStream(fis, digest);

List<BoxFileUploadSessionPart> parts = new ArrayList<BoxFileUploadSessionPart>();

//Get the part size. Each uploaded part should match the part size returned as part of the upload session.
//The last part of the file can be less than part size if the remaining bytes of the last part is less than
//the given part size
long partSize = sessionInfo.getPartSize();
//Start byte of the part
long offset = 0;
//Overall of bytes processed so far
long processed = 0;
while (processed < fileSize) {
long diff = fileSize - processed;
//The size last part of the file can be lesser than the part size.
if (diff < partSize) {
partSize = diff;
}

//Generate a unique partId
String partId = LargeFileUpload.generateHex();
//Upload a part. It can be uploaded asynchorously
BoxFileUploadSessionPart part = session.uploadPart(partId, dis, offset, partSize, fileSize);
parts.add(part);

//Increase the offset and proceesed bytes to calculate the Content-Range header.
processed += partSize;
offset += partSize;
}
```

At any point in time, the list of parts that are being uploaded successfully can be retrivied with the
[`listParts(marker, limit)`][list-parts] method of the session instance.

```java
//The following snippet retrives first 1000 parts that are uploaded. Both can be modified based on the needs.
BoxFileUploadSessionPartList partList = session.listParts(0, 1000);
List<BoxFileUploadSessionPart> parts = partList.getParts();
```
Once all the parts are uploaded successfully. the upload sessiion can be commited with the
[`commit(digest, parts, attributes, ifMatch, ifNoneMatch)`][upload-session-commit] method.

```java
//Creates the file hash
byte[] digestBytes = digest.digest();
//Base64 encoding of the hash
String digestStr = Base64.encode(digestBytes);

//Commit the upload session. If there is a failure, abort the commit.
BoxFile.Info fileInfo = session.commit(digestStr, parts, null, null, null);
```

The upload session can be aborted at any time with the [`abort()`][upload-session-abort] method of the session instance.

```java
session.abort();
```

The upload session status can be retrived at any time with the [`getstatus()`][upload-session-status] method.
This call will update the parts processed and other information in the session info instance.
```java
BoxFileUploadSession.Info updatedSessionInfo = session.getStatus();
```

[create-upload-session]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFolder.html#createUploadSession(java.lang.String,%20long)

Create a large File
-------------------

A large file can be uploaded with the [`uploadLargeFile(InputStream, fileName, fileSize)`][upload-large-file] method.

```java
File myFile = new File("My Large_File.txt");
FileInputStream stream = new FileInputStream(myFile);

BoxFolder rootFolder = BoxFolder.getRootFolder(api);
BoxFile.Info fileInfo = rootFolder.uploadLargeFile(inputStream, "My_Large_File.txt", myFile.length());
```

[upload-large-file]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFolder.html#uploadLargeFile(java.io.InputStream,%20java.lang.String,%20long)


Copy a File
-----------

Expand Down Expand Up @@ -238,6 +352,122 @@ firstVersion.delete();

[delete-version]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFileVersion.html#delete()

Create a versioning of a large File by uploading its content in chunks
----------------------------------------------------------------------

An upload session can be created with the [`createUploadSession(fileSize)`][create-upload-session-version]
method to upload new version of a large file in chunks.

```java
BoxFile file = new BoxFile(api, "id");
BoxFileUploadSession.Info session = file.createUploadSession(fileSize);

//Get the session resource from the session info
BoxFileUploadSession session = sessionInfo.getResource();

//Create the Message Digest for the whole file
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA1");
} catch (NoSuchAlgorithmException ae) {
throw new BoxAPIException("Digest algorithm not found", ae);
}
```
Once the upload session is created, the large file can be uploaded in chuncks with the
[`uploadPart(partId, stream, offset, partSize, totalSizeOfFile)`][upload-part] method of the session instance.
If there is a failure in uploading any of the parts, the failed part can be uploaded again without
affecting the other parts.

```java
//Reading a large file
FileInputStream fis = new FileInputStream("My_Large_File.txt");
//Create the digest input stream to calculate the digest for the whole file.
DigestInputStream dis = new DigestInputStream(fis, digest);

List<BoxFileUploadSessionPart> parts = new ArrayList<BoxFileUploadSessionPart>();

//Get the part size. Each uploaded part should match the part size returned as part of the upload session.
//The last part of the file can be less than part size if the remaining bytes of the last part is less than
//the given part size
long partSize = sessionInfo.getPartSize();
//Start byte of the part
long offset = 0;
//Overall of bytes processed so far
long processed = 0;
while (processed < fileSize) {
long diff = fileSize - processed;
//The size last part of the file can be lesser than the part size.
if (diff < partSize) {
partSize = diff;
}

//Generate a unique partId
String partId = LargeFileUpload.generateHex();
//Upload a part. It can be uploaded asynchorously
BoxFileUploadSessionPart part = session.uploadPart(partId, dis, offset, partSize, fileSize);
parts.add(part);

//Increase the offset and proceesed bytes to calculate the Content-Range header.
processed += partSize;
offset += partSize;
}
```
At any point in time, the list of parts that are being uploaded successfully can be retrivied with the
[`listParts(marker, limit)`][list-parts] method of the session instance.

```java
//The following snippet retrives first 1000 parts that are uploaded. Both can be modified based on the needs.
BoxFileUploadSessionPartList partList = session.listParts(0, 1000);
List<BoxFileUploadSessionPart> parts = partList.getParts();
```
Once all the parts are uploaded successfully. the upload sessiion can be commited with the
[`commit(digest, parts, attributes, ifMatch, ifNoneMatch)`][upload-session-commit] method.

```java
//Creates the file hash
byte[] digestBytes = digest.digest();
//Base64 encoding of the hash
String digestStr = Base64.encode(digestBytes);

//Commit the upload session. If there is a failure, abort the commit.
BoxFile.Info fileInfo = session.commit(digestStr, parts, null, null, null);
```

The upload session can be aborted at any time with the [`abort()`][upload-session-abort] method of the session instance.

```java
session.abort();
```

The upload session status can be retrived at any time with the [`getstatus()`][upload-session-status] method.
This call will update the parts processed and other information in the session info instance.
```java
BoxFileUploadSession.Info sessionInfo = session.getStatus();
```

[create-upload-session-version]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFile.html#uploadVersion(long)
[upload-part]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFileUploadSession.html#uploadPart(java.lang.String,%20java.io.InputStream,%20long,%20long,%20long)
[list-parts]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFileUploadSession.html#listParts(int,%20int)
[upload-session-commit]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFileUploadSession.html#commit(java.lang.String,%20java.util.List,%20java.util.Map,%20java.lang.String,%20java.lang.String)
[upload-session-abort]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFileUploadSession.html#abort()
[upload-session-status]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFileUploadSession.html#getStatus()

Create new version of a large File
----------------------------------

New versions of a large file can be uploaded with the
[`uploadLargeFile(InputStream, fileSize)`][upload-large-file-version] method.

```java
File myFile = new File("My File.txt");
FileInputStream stream = new FileInputStream(myFile);

BoxFile file = new BoxFile(api, "id");
BoxFile.Info versionedFileInfo = file.uploadLargeFile(inputStream, myFile.length());
```

[upload-large-file-version]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFile.html#uploadLargeFile(java.io.InputStream,%20long)

Lock a File
-----------

Expand Down Expand Up @@ -357,3 +587,17 @@ file.deleteMetadata();
[delete-metadata-2]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFile.html#deleteMetadata(java.lang.String)
[delete-metadata-3]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFile.html#deleteMetadata(java.lang.String,%20java.lang.String)

Get All Metadata on File
--------------

[`getAllMetadata(String...)`][get-all-metadata] method will return an iterable that will page through all of the metadata associated with the file.

```java
BoxFile file = new BoxFile(api, "id");
Iterable<Metadata> metadataList = file.getAllMetadata("name", "description");
for (Metadata metadata : metadataList) {
// Do something with the metadata.
}
```

[get-all-metadata]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFile.html#getAllMetadata(java.lang.String...)
Loading