[英]Scala amazon S3 file upload show error not found
I am using the playframework 2.4.6 and trying to upload a file to my S3 bucket but I get an error on compilation: Not Found value s3. 我正在使用playframework 2.4.6并尝试将文件上传到我的S3存储桶,但是在编译时出现错误:未找到值s3。 I am basically trying to copy this tutorial https://github.com/Kaliber/play-s3 and also this post which is similar Play!
我基本上是在尝试复制本教程https://github.com/Kaliber/play-s3以及与Play类似的帖子! Upload file and save to AWS S3 .
上传文件并保存到AWS S3 。 My information is as follow:
我的信息如下:
Build.SBT 构建SBT
val appDependencies = Seq(
"net.kaliber" %% "play-s3" % "7.0.1",
"net.kaliber" %% "play-s3" % "7.0.2"
)
Application.conf Application.conf
aws.accessKeyId="akey"
aws.secretKey="skey"
then my controller 然后我的控制器
def upload= Action.async(parse.multipartFormData) {implicit request =>
request.body.file("file").map { file =>
// implicit val credential = AwsCredentials.fromConfiguration
val byteArray = Files.readAllBytes(Paths.get(file.ref.file.getPath))
val bucket = S3("myBuckets")
val result = bucket + BucketFile(file.filename, file.contentType.get, byteArray, None, None)
result.map { unit =>
Ok("File uploaded")
}.getOrElse {
Redirect(routes.Application.index).flashing(
"error" -> "Missing file"
)
}
}
}
I am getting the error on val bucket = S3("myBuckets") as stated before it says Not found value S3 and the build crashes. 如前所述,我在val bucket = S3(“ myBuckets”)上遇到错误,它说未找到值S3,并且构建崩溃。 I do not know if I could be missing an import as my IDE does not point it out ... This is my imports for the controller:
我不知道是否会丢失导入,因为我的IDE并未指出...这是控制器的导入:
import play.api.data.Form
import play.api.libs.json.{Json, JsValue}
import play.api.mvc.{Action, Controller}
import play.mvc.Result
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import java.io.File
Try importing: 尝试导入:
fly.play.s3._
Or if you want to be specific: 或者,如果您想具体说明:
fly.play.s3.S3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.