frictionlessdata / tableschema-java

A Java library for working with Table Schema.
MIT License
25 stars 21 forks source link

As a user of the lib, I'd like to be able to specify local file paths, not only URLs #64

Closed sashamitrovich closed 2 years ago

sashamitrovich commented 3 years ago

Overview

Not a bug, could be a documentation issue: is it possible to specify local FS path instead of a URL?

Please preserve this line to notify @iSnow (lead of this repository)

sashamitrovich commented 3 years ago

This would work, right: Table.fromSource(dataSource, schema, format) ?

iSnow commented 3 years ago

No, that won't work, the "dataSource" parameter is intended to be a JSON string, (Javadoc is there)

If you want to specify a local FS path, you need to go with fromSource(File dataSource, File basePath, Schema schema, CSVFormat format). Parameger formatcan be null to use the default format.

dataSource has to be a relative File path, basePath a File pointing to a path to resolve against. The reason is to prevent a class of possible exploits (discussed in "Security" on the Frictionless Data website). Unfortunately, the threat mitigation is over the top if you only want to use TableSchema code, not Datapackages, but I don't have the time to refactor everything to do all security checks in the DP code.

The code for Table discriminates between Table creation from scratch (the c'tor) and reading an existing Table (the fromSource() methods).

If you can help out by amending the examples/docs, I am more than happy to include it.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.