Quantcast

Example for gorm-couchdb plugin attachment support

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Example for gorm-couchdb plugin attachment support

Burkard Endres
can anyone give me a hint how to use attachment support of gorm-couchdb plugin?
I did not find any documentation for that and have absolutely no idea how to use it.
Any hint will be welcome.

Burkard
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Example for gorm-couchdb plugin attachment support

Warner Onstine-3
Hi Burkard, I'll have to check with Cory on this (the plugin
co-author), I know the underlying library we use supports it but I'm
not sure our plugin does.

-warner

On Sat, Jul 17, 2010 at 9:00 AM, [hidden email] <[hidden email]> wrote:
> can anyone give me a hint how to use attachment support of gorm-couchdb
> plugin?
> I did not find any documentation for that and have absolutely no idea how to
> use it.
> Any hint will be welcome.
> Burkard

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fwd: [grails-user] Example for gorm-couchdb plugin attachment support

Warner Onstine-3
In case others didn't see this, not sure if it made it to the list.

-warner


---------- Forwarded message ----------
From: Cory Hacking <[hidden email]>
Date: Sat, Jul 17, 2010 at 12:18 PM
Subject: Re: [grails-user] Example for gorm-couchdb plugin attachment support
To: Warner Onstine <[hidden email]>
Cc: [hidden email]


The plugin does support attachments, there are a few simple tests that
you can also use as examples in the github project located here
http://github.com/coryhacking/gorm-couchdb/blob/master/test/integration/org/codehaus/groovy/grails/plugins/couchdb/test/AttachmentsTests.groovy
You first need to start by adding an attachments field to your domain
object.  I'll use an example of a news story domain object that
includes a picture as an attachment:

@CouchEntity
class Story {
String headline
Date publishDate
String author
Map<String, Attachment> attachments
}

The plugin recognizes this as the special couchdb _attachments field.
To save the photo as part of a controller, you can do something like
this:

if (!news.hasErrors() && news.save()) {
image = request.getFile('photo') if (image && image.size > 0) {
news.saveAttachment("photo.jpg", image.getContentType(),
image.getBytes()) } }

You can also call deleteAttachment(attachmentId) to delete the
attachment; and news.readAttachment(attachmentId) to read it.
-Cory
On Jul 17, 2010, at 11:41 AM, Warner Onstine wrote:

Hi Burkard, I'll have to check with Cory on this (the plugin
co-author), I know the underlying library we use supports it but I'm
not sure our plugin does.

-warner

On Sat, Jul 17, 2010 at 9:00 AM, [hidden email] <[hidden email]> wrote:

can anyone give me a hint how to use attachment support of gorm-couchdb

plugin?

I did not find any documentation for that and have absolutely no idea how to

use it.

Any hint will be welcome.

Burkard

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...