question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support GridFS [moved]

See original GitHub issue

This is Issue 153 moved from a Google Code project. Added by 2010-11-02T17:41:54.000Z by scotthernandez. Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Enhancement, Priority-Low, Milestone-Release1.0

Original description

There are two ways I can see supporting gridfs.
1.) Add a special type/annotation that can be used as a reference to a gridfs file (by path or _id)

class HasAFileRef {
@Id ObjectId id;
@GridFS OutputStream/GridFSDBFile/byte[] gridFsFile;
...
}

2.) Wrap a class as the gridfsfile.metadata fields.

@GridFsFile
class IsAFile {
@Id ObjectId id;
String field1; // maps to metadata.field1
...
[GridFSFile gfsFile;]
}

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
schmitzhermescommented, Feb 27, 2017

are there any updates on this?

0reactions
heruancommented, May 4, 2022

Thanks! I misinterpreted your last message as if Morphia had already some support to map files to entities. This is the use case I have right now:

class Attachment {
    String id;
    String name;
    Blob data;
}

This is a JPA-mapped entity which uses the Blob type to read from database, i.e. data.getBinaryStream() which reads from the database (without loading all the bytes in memory).

I’m moving from JPA to Morphia and I don’t really know how to migrate this last bit of logic!

It would then be used like:

InputStream downloadAttachment(String id) {
    return repository.find(id).getData().getBinaryStream();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

GridFS — MongoDB Manual
GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit ... GridFS does not support multi-document transactions.
Read more >
GridFS and Cloning to another server - Stack Overflow
I have a local MongoDB database that I am starting to put some files into GridFS for caching purposes. What I want to...
Read more >
GridFS API - GitHub Pages
The MongoDB Node.js driver now supports a stream-based API for GridFS that's compatible with Node.js' streams3, so you can .pipe() directly from file ......
Read more >
Support for GridFS - Google Groups
MongoDB and. Mongoose to persist user data and picture metadata. We are planning to move our pictures from the filesystem into mongo's
Read more >
Howto migrate the files from gridfs to filesystem
Not tested… purely psuedo · Set your file store to filesystem and set your folder. · Then export all of the files from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found