Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add type support for java.nio.file.Path ... such that it stores the underlying URI as VARCHAR/string #651

Closed
icode opened this issue Apr 14, 2016 · 19 comments
Assignees
Milestone

Comments

@icode
Copy link
Contributor

icode commented Apr 14, 2016

support java.io.File and java.nio.file.Path save to db.

db data type use Blob, can configure save file bytes or file path.

add plan column can use for witch read file bytes or file path, both plan use

and more info last modified, size, filename and more

@rbygrave
Copy link
Member

You need to expand and explain more clearly exactly what is desired.

Ebean already supports java.io.File - it streams into a DB Clob or Blob type.

@icode
Copy link
Contributor Author

icode commented Apr 14, 2016

save file has two way

  1. save file content bytes
  2. save file OS location (file path)

sometimes, we need save file content to db. and sometimes, we save file path, read system path.

so, we need switch save plan.

@rbygrave
Copy link
Member

Yes, I don't think I like this option 2. of having Ebean store the file
path. Whenever I have needed to store a 'file path' I have done this in my
application (so the entity bean has a String property for the path). That
means the application can deal with relative paths, temp directories, S3
paths etc.

I don't see option 2 as a good thing for Ebean to do.

Saving the File content however is really good because it handles the
streaming aspect making it really easy to deal with large content
(streaming the content into and out of the DB).

... but no I don't see "2. save file OS location (file path)" as something
Ebean should do but instead application code should do.

On 14 April 2016 at 16:28, icode notifications@github.com wrote:

save file has two way

  1. save file content bytes
  2. save file OS location (file path)

sometimes, we need save file content to db. and sometimes, we save file
path, read system path.

so, we need switch save plan.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#651 (comment)

@icode
Copy link
Contributor Author

icode commented Apr 14, 2016

save file content to db is low read speed at DB data too large.
but small application and small data save file content to DB is easy and convenience.

about support java.nio.Path

Path can custom FileSystem , so file can save any way (PAAS, HDFS, S3 etc) and not change code.

@icode
Copy link
Contributor Author

icode commented Apr 14, 2016

and how to read bytes streaming? not all bytes

@rbygrave
Copy link
Member

how to read bytes streaming? not all bytes

Do you mean how to stream only part of the bytes? You can't, you need to use the java.sql.Clob API to do that. With the File type all the bytes are streamed in and out.

about support java.nio.Path

You can just do Path.toFile() in the application of course but sure. Is that what you want this ticket to be? An enhancement request to add support for java.nio.Path?

@icode
Copy link
Contributor Author

icode commented Apr 18, 2016

Path can support muitl file type and transparent for developer

@rbygrave
Copy link
Member

Is that what you want this ticket to be?

An enhancement request to add support for java.nio.Path (just like the current File support) ?

@icode
Copy link
Contributor Author

icode commented Apr 18, 2016

File != Path.toFile() because Path can any protocol, http HDSF etc.

@icode
Copy link
Contributor Author

icode commented Apr 18, 2016

en, like current File support, but Path should save Path.toString() or URI ?

@rbygrave
Copy link
Member

That is not how File support works. File support is used to stream the content into/out of the DB. It is NOT used to store the file path.

If you want Path.toString() etc then no, I will not add support for that as per the prior comments.

@icode
Copy link
Contributor Author

icode commented Apr 18, 2016

support Path user can less code.

// read file from db
Paths.get(URI.create("db:///xxx/1"));
// read file from http
Paths.get(URI.create("http://www.xx.com/1"));
// read file from hdfs
Paths.get(URI.create("hdfs:///a/1"));
// etc ..

save path Path.toUri() to DB.

@icode
Copy link
Contributor Author

icode commented Apr 18, 2016

and developer can do not know file how to save, any FileSystem.

Files.size(path);
Files.getLastModifiedTime(path);
Files.readAllBytes(path);
// etc ...

@icode
Copy link
Contributor Author

icode commented Apr 18, 2016

You understand what I'm saying what?

@rbygrave
Copy link
Member

I think you want to support the Path type specifically by persisting the URI string value and then converting that back from String to URI to Path.

Is that correct?

@icode
Copy link
Contributor Author

icode commented Apr 18, 2016

yes, but not change code, use Path not URI.

see https://docs.oracle.com/javase/8/docs/technotes/guides/io/fsp/filesystemprovider.html

and can use api Paths.get(uri)

@icode
Copy link
Contributor Author

icode commented Apr 18, 2016

Path like Apache Commons VFS and best

@rbygrave rbygrave changed the title Support select plan for file and path save to db ENH: Add type support for java.nio.file.Path ... such that it stores the underlying URI as VARCHAR/string Apr 20, 2016
@rbygrave rbygrave added this to the 7.8.1 milestone Apr 20, 2016
@rbygrave rbygrave self-assigned this Apr 20, 2016
rbygrave added a commit that referenced this issue Apr 20, 2016
…stores the underlying URI as VARCHAR/string
rbygrave added a commit that referenced this issue Apr 20, 2016
…stores the underlying URI as VARCHAR/string
@rbygrave
Copy link
Member

Ok done and pushed. Supports Path ... by translating it into a String via URI to save as VARCHAR.

@rbygrave
Copy link
Member

I'll close this now. Let me know if that is different to what you expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants