Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Latest commit

 

History

History
69 lines (51 loc) · 1.3 KB

README.md

File metadata and controls

69 lines (51 loc) · 1.3 KB

Analog Web Framework Commons File Upload Plugin

Enable uploading file to Analogweb's routing endpoint. (NOT needs Servlet API.)

Example In Scala

Add SBT dependency.(scala-plugin includes this plugin on dependency.)

val scalaplugin = "org.analogweb" %% "analogweb-scala" % "0.9.6-SNAPSHOT"

Write them.

import org.analogweb.core.httpserver.HttpServers
import org.analogweb.scala.Analogweb

class Hello extends Analogweb {

  def upload = post("/upload") { implicit request => 
    multipart.as[java.io.File]("file").map { f =>
      // Read contents.
      ...
      Ok
    }.getOrElse(BadRequest)
  }

}

Example In Java

Add Maven dependency.

<dependency>
 <groupId>org.analogweb</groupId>
 <artifactId>analogweb-commons-fileupload</artifactId>
 <version>0.9.6-SNAPSHOT</version>
</dependency>

Write them.

package org.analogweb.hello;

import org.analogweb.annotation.Route;
import org.analogweb.annotation.Post;
import org.analogweb.acf.MultipartParam;

@Route("/")
public class Hello {

  @Route
  @Post
  public String upload(@MultipartParam("file") File uploaded) {
    // Read contents.
    ...
    return "File received.";
  }

}