Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 8744d7b

Browse files
SynapticloopSynapticloop
authored andcommitted
Merge branch 'master' of https://github.com/iterate-ch/backblaze-b2-java-api into iterate-ch-master
2 parents 1f9a37f + 4505ea0 commit 8744d7b

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/main/java/synapticloop/b2/response/B2FileInfoResponse.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
* this source code or binaries.
1717
*/
1818

19-
import java.util.HashMap;
20-
import java.util.Iterator;
21-
import java.util.Map;
22-
2319
import org.json.JSONObject;
2420
import org.slf4j.Logger;
2521
import org.slf4j.LoggerFactory;
26-
2722
import synapticloop.b2.Action;
2823
import synapticloop.b2.exception.B2ApiException;
2924

25+
import java.util.HashMap;
26+
import java.util.Iterator;
27+
import java.util.Map;
28+
3029
public class B2FileInfoResponse extends BaseB2Response {
3130
private static final Logger LOGGER = LoggerFactory.getLogger(B2FileInfoResponse.class);
3231

3332
private final String fileId;
3433
private final String fileName;
34+
private final String contentType;
3535
private final String contentSha1;
3636
private final Long contentLength;
3737

@@ -55,10 +55,11 @@ public B2FileInfoResponse(final JSONObject response) throws B2ApiException {
5555
this.fileId = this.readString(B2ResponseProperties.KEY_FILE_ID);
5656
this.fileName = this.readString(B2ResponseProperties.KEY_FILE_NAME);
5757
this.contentLength = this.readLong(B2ResponseProperties.KEY_CONTENT_LENGTH);
58+
this.contentType = this.readString(B2ResponseProperties.KEY_CONTENT_TYPE);
5859
this.contentSha1 = this.readString(B2ResponseProperties.KEY_CONTENT_SHA1);
5960
this.fileInfo = new HashMap<String, String>();
6061

61-
JSONObject fileInfoObject = response.optJSONObject(B2ResponseProperties.KEY_FILE_INFO);
62+
JSONObject fileInfoObject = this.readObject(B2ResponseProperties.KEY_FILE_INFO);
6263
if(null != fileInfoObject) {
6364
Iterator keys = fileInfoObject.keys();
6465
while (keys.hasNext()) {
@@ -101,7 +102,12 @@ public B2FileInfoResponse(final JSONObject response) throws B2ApiException {
101102
* @return the length of content for this file
102103
*/
103104
public long getContentLength() { return this.contentLength; }
104-
105+
106+
/**
107+
* @return the MIME type of the file
108+
*/
109+
public String getContentType() { return contentType; }
110+
105111
/**
106112
* Get the sha1 hash of the content - this can be used to verify the
107113
* integrity of the downloaded file
@@ -147,6 +153,7 @@ public String toString() {
147153
sb.append("fileId='").append(fileId).append('\'');
148154
sb.append(", fileName='").append(fileName).append('\'');
149155
sb.append(", contentLength=").append(contentLength);
156+
sb.append(", contentType=").append(contentType);
150157
sb.append(", contentSha1='").append(contentSha1).append('\'');
151158
sb.append(", fileInfo=").append(fileInfo);
152159
sb.append(", size=").append(size);

0 commit comments

Comments
 (0)