OSDN Git Service

Change the Atach from the File to the lob.
authoruyaji <yuichiro.uyama@gmail.com>
Wed, 18 Dec 2013 00:06:21 +0000 (09:06 +0900)
committeruyaji <yuichiro.uyama@gmail.com>
Wed, 18 Dec 2013 00:06:21 +0000 (09:06 +0900)
PartsList/PartsList/app/models/Atach.scala
PartsList/PartsList/app/models/services/AtachManager.scala
PartsList/PartsList/attach/accept.jpg [deleted file]
PartsList/PartsList/attach/clock.jpeg [deleted file]
PartsList/PartsList/attach/clock.png [deleted file]
PartsList/PartsList/attach/correct.jpeg [deleted file]
PartsList/PartsList/attach/judas.jpg [deleted file]
PartsList/PartsList/attach/kaminari-mon.gif [deleted file]
PartsList/PartsList/attach/mistake.jpeg [deleted file]
PartsList/PartsList/attach/ozzy.jpg [deleted file]

index 566e618..1d981b4 100644 (file)
@@ -1,7 +1,7 @@
 package models
 import org.squeryl.KeyedEntity
 import org.squeryl.dsl._
-case class Atach(contentType:String, fileName:String, grpName:String, partId:Long=0, notifyId:Long=0, replyId:Long=0) extends KeyedEntity[Long]{
+case class Atach(lob:Array[Byte], contentType:String, fileName:String, grpName:String, partId:Long=0, notifyId:Long=0, replyId:Long=0) extends KeyedEntity[Long]{
   val id:Long=0
 
   lazy val part: ManyToOne[Part] = PartsListDb.partsAtache.right(this)
index 26cd046..4bb97c1 100644 (file)
@@ -8,16 +8,29 @@ import org.squeryl._
 import org.squeryl.dsl._
 import org.squeryl.PrimitiveTypeMode._
 import java.io.FileInputStream
+import java.io.FileOutputStream
+import java.io.BufferedInputStream
+import java.io.BufferedOutputStream
 
 case class AtachManager(){
   def uploadAtach(atach:FilePart[TemporaryFile], grpName:String, partId:Long, notifyId:Long, replyId:Long) = {
       val filename = atach.filename
       val contentType = atach.contentType
-      var folder = Messages("atach.folder")
+      val file = atach.ref.file
+      val fis = new FileInputStream(file)
+      val bis = new BufferedInputStream(fis)
+      val  byteBuffer = new Array[Byte](file.length().toInt)
+      bis.read(byteBuffer)
+      bis.close()
+      fis.close()
+      //実ファイルで実装するなら以下5行で実装
+/*      var folder = Messages("atach.folder")
       if(!folder.endsWith("/")) {folder = folder.concat("/")}
-      val url = folder + filename
+      val url = folder + filename  
+      val file = new File(url)
       atach.ref.moveTo(new File(url), true)
-      val newAtach = Atach(contentType.get, filename, grpName, partId, notifyId, replyId)
+*/    
+      val newAtach = Atach(byteBuffer, contentType.get, filename, grpName, partId, notifyId, replyId)
       if(partId != 0) {
         associateAtach(PartManager(), partId, newAtach)
        }
@@ -31,12 +44,14 @@ case class AtachManager(){
   
   def showAtach(id: Long):Array[Byte] = {
     val atach = getById(id)
-    val file = new File(Messages("atach.folder") + "/" + atach.fileName)
+    return atach.lob
+    // 実ファイルで実装するなら以下5行
+/*    val file = new File(Messages("atach.folder") + "/" + atach.fileName)
     val data = new Array[Byte](file.length().asInstanceOf[Int])
     val io = new FileInputStream(file)
     io.read(data)
     io.close
-    return data
+    return data*/
   }
   
   def getById(id: Long):Atach = {
diff --git a/PartsList/PartsList/attach/accept.jpg b/PartsList/PartsList/attach/accept.jpg
deleted file mode 100644 (file)
index af99a99..0000000
Binary files a/PartsList/PartsList/attach/accept.jpg and /dev/null differ
diff --git a/PartsList/PartsList/attach/clock.jpeg b/PartsList/PartsList/attach/clock.jpeg
deleted file mode 100644 (file)
index d69dfc6..0000000
Binary files a/PartsList/PartsList/attach/clock.jpeg and /dev/null differ
diff --git a/PartsList/PartsList/attach/clock.png b/PartsList/PartsList/attach/clock.png
deleted file mode 100644 (file)
index bb57f1a..0000000
Binary files a/PartsList/PartsList/attach/clock.png and /dev/null differ
diff --git a/PartsList/PartsList/attach/correct.jpeg b/PartsList/PartsList/attach/correct.jpeg
deleted file mode 100644 (file)
index c9353ec..0000000
Binary files a/PartsList/PartsList/attach/correct.jpeg and /dev/null differ
diff --git a/PartsList/PartsList/attach/judas.jpg b/PartsList/PartsList/attach/judas.jpg
deleted file mode 100644 (file)
index 977c6cd..0000000
Binary files a/PartsList/PartsList/attach/judas.jpg and /dev/null differ
diff --git a/PartsList/PartsList/attach/kaminari-mon.gif b/PartsList/PartsList/attach/kaminari-mon.gif
deleted file mode 100644 (file)
index 9db4a69..0000000
Binary files a/PartsList/PartsList/attach/kaminari-mon.gif and /dev/null differ
diff --git a/PartsList/PartsList/attach/mistake.jpeg b/PartsList/PartsList/attach/mistake.jpeg
deleted file mode 100644 (file)
index 029d21c..0000000
Binary files a/PartsList/PartsList/attach/mistake.jpeg and /dev/null differ
diff --git a/PartsList/PartsList/attach/ozzy.jpg b/PartsList/PartsList/attach/ozzy.jpg
deleted file mode 100644 (file)
index dd94394..0000000
Binary files a/PartsList/PartsList/attach/ozzy.jpg and /dev/null differ