Skip to content

Commit 236ea5f

Browse files
Small changes, allow Image path and data to be read from a datapackage
1 parent f3aa657 commit 236ea5f

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>io.frictionlessdata</groupId>
55
<artifactId>datapackage-java</artifactId>
6-
<version>0.6.2-SNAPSHOT</version>
6+
<version>0.6.4-SNAPSHOT</version>
77
<packaging>jar</packaging>
88
<issueManagement>
99
<url>https://github.com/frictionlessdata/datapackage-java/issues</url>
@@ -20,7 +20,7 @@
2020
<java.version>8</java.version>
2121
<maven.compiler.source>${java.version}</maven.compiler.source>
2222
<maven.compiler.target>${java.version}</maven.compiler.target>
23-
<tableschema-java-version>0.6.2</tableschema-java-version>
23+
<tableschema-java-version>0.6.4</tableschema-java-version>
2424
<hamcrest.version>1.3</hamcrest.version>
2525
<junit.version>5.9.1</junit.version>
2626
<slf4j-simple.version>2.0.5</slf4j-simple.version>

src/main/java/io/frictionlessdata/datapackage/Package.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ public Package(Collection<Resource> resources) throws IOException {
9090
}
9191

9292
/**
93-
* Load from String representation of JSON object. To prevent file system traversal attacks,
94-
* the basePath must be explicitly set here, the `basePath` variable cannot be null.
93+
* Load from String representation of JSON object. To prevent file system traversal attacks
94+
* while loading Resources, the basePath must be explicitly set here, the `basePath`
95+
* variable cannot be null.
9596
*
9697
* The basePath is the path that is used as a jail root for Resource creation -
9798
* no absolute paths for Resources are allowed, they must all be relative to and
@@ -263,10 +264,26 @@ public URL getHomepage() {
263264
return homepage;
264265
}
265266

266-
public String getImage() {
267+
/**
268+
* Returns the path or URL for the image according to the spec:
269+
* https://specs.frictionlessdata.io/data-package/#image
270+
*
271+
* @return path or URL to the image data
272+
*/
273+
public String getImagePath() {
267274
return image;
268275
}
269276

277+
/**
278+
* Returns the image data if the image is stored inside the data package, null if {@link #getImagePath()}
279+
* would return a URLL
280+
*
281+
* @return binary image data
282+
*/
283+
public byte[] getImage() {
284+
return imageData;
285+
}
286+
270287
public ZonedDateTime getCreated() {
271288
return created;
272289
}

0 commit comments

Comments
 (0)