Hello everyone,
I'm not sure if this is a lift problem or it's me. I'm trying to add
the ability to upload images to a project - I'm using the code
explained here:
http://groups.google.com/group/liftweb/browse_thread/thread/b0509263e18c9a66/f36535bbe15273d6?lnk=gst&q=image+upload#f36535bbe15273d6

I added two mapper classes:
-------
class ImageInfo extends LongKeyedMapper[ImageInfo] with IdPK {
  def getSingleton = ImageInfo

  object date extends MappedLong(this) {
    override def defaultValue = Helpers.millis
  }
  object mimeType extends MappedPoliteString(this, 64)
  object name extends MappedPoliteString(this, 256) {
    override def dbIndexed_? = true
    override def defaultValue = ""

    private def noSlashes(s: String) : List[FieldError] =
      if (s.contains("/"))
                                List(FieldError(this, Text("Image name \"" + s 
+ "\" may not
contain \"/\"")))
      else
                                Nil

    override def validations =
      valMinLen(1, "Image name must not be empty") _ ::
      valUnique("Image name must be unique") _ ::
      noSlashes _ ::
      super.validations
  }

  object blob extends MappedLongForeignKey(this, ImageBlob)

  def deleteWithBlob {
    this.blob.obj match {
      case Full(x) => x.delete_!
      case _ =>
    }
    this.delete_!
  }
}
---------
and
----------
class ImageBlob extends LongKeyedMapper[ImageBlob] with IdPK {
  def getSingleton = ImageBlob

  object image extends MappedBinary(this)
}
---------

The schemifier couldn't create the tables it gave to following
error ::
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'blob BIGINT UNSIGNED)  ENGINE = InnoDB' at line 1

this is the sql statement it tried to execute

CREATE TABLE imageinfo (name VARCHAR(256) , id BIGINT UNSIGNED NOT
NULL AUTO_INCREMENT UNIQUE KEY , date_c BIGINT , mimetype
VARCHAR(64) , blob BIGINT UNSIGNED)  ENGINE = InnoDB

I fixed the sql statement and created the table manually - but now i
get the following error whenever i try to store an image:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'blob,date_c,mimetype,name) VALUES (1,1267705056327,'image/
jpeg','Photo 1.jpg')'

Does anyone know if this is related to llift or if I'm doing something
wrong?

Thanks
Mads Hartmann Jensen

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to