本文整理汇总了Scala中java.nio.file.StandardCopyOption类的典型用法代码示例。如果您正苦于以下问题:Scala StandardCopyOption类的具体用法?Scala StandardCopyOption怎么用?Scala StandardCopyOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StandardCopyOption类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: Access
//设置package包名称以及导入依赖的类
package hu.blackbelt.cd.bintray.deploy
import java.nio.file.{Files, StandardCopyOption}
import java.util.{Properties, UUID}
import awscala.s3.S3
import com.amazonaws.regions.Regions
import com.amazonaws.services.s3.model.GetObjectRequest
import hu.blackbelt.cd.bintray.VFS.FS
object Access {
val bintray_organization = "bintray.organization"
val bintray_user = "bintray.user"
val bintray_apikey = "bintray.apikey"
val aws_accessKeyId = "aws.accessKeyId"
val aws_secretKey = "aws.secretKey"
def collect = {
implicit val s3 = S3()(com.amazonaws.regions.Region.getRegion(Regions.EU_CENTRAL_1))
val destination = FS.getPath(s"/tmp/${UUID.randomUUID().toString}")
Files.createDirectories(destination)
val s3Object = s3.getObject(new GetObjectRequest("blackbelt-secrets", "bintray-deploy/access.properties"))
Files.copy(s3Object.getObjectContent, destination, StandardCopyOption.REPLACE_EXISTING)
import scala.collection.JavaConverters._
val prop = new Properties()
prop.load(Files.newInputStream(destination))
prop.entrySet().asScala.foreach {
(entry) => {
sys.props += ((entry.getKey.asInstanceOf[String], entry.getValue.asInstanceOf[String]))
}
}
}
}
开发者ID:tsechov,项目名称:s3-bintray-deploy,代码行数:39,代码来源:Access.scala
示例2: Directories
//设置package包名称以及导入依赖的类
import java.net.URI
import java.nio.file.attribute.{FileAttribute, BasicFileAttributes}
import java.nio.file.{StandardCopyOption, Paths, Files, Path}
import io.gatling.core.util.PathHelper._
class Directories(
val data: Path,
val bodies: Path,
val binaries: Path,
val results: Path
)
object IDEPathHelper {
private val uri: URI = getClass.getClassLoader.getResource("gatling.conf").toURI
val directories: Directories = if (uri.getScheme.startsWith("jar")) {
val testDir = System.getProperty("test.dir");
val mainDir: Path = if (testDir != null) {
val dir = Paths.get(testDir);
if (dir.exists) {
if (!dir.isDirectory) {
throw new IllegalArgumentException(testDir + " is not a directory")
}
dir
} else {
Files.createDirectory(dir)
}
} else {
Files.createTempDirectory("gatling-")
}
System.out.println("Using " + mainDir + " as gatling directory")
// unpack gatling.conf
Files.copy(getClass.getResourceAsStream("gatling.conf"), mainDir.resolve("gatling.conf"), StandardCopyOption.REPLACE_EXISTING)
// using createDirectories to ignore existing
val directories = new Directories(
Files.createDirectories(mainDir.resolve("data")),
Files.createDirectories(mainDir.resolve("bodies")),
Files.createDirectories(mainDir.resolve("binaries")),
Files.createDirectories(mainDir.resolve("results")))
val simulationFile: String = Engine.simulationClass.replace('.', '/') + ".class"
// unpack simulation
val targetFile: Path = mainDir.resolve("binaries").resolve(simulationFile)
Files.createDirectories(targetFile.getParent)
Files.copy(getClass.getResourceAsStream(simulationFile), targetFile, StandardCopyOption.REPLACE_EXISTING)
directories
} else {
val projectRootDir = RichPath(uri).ancestor(3)
val mavenResourcesDirectory = projectRootDir / "src" / "test" / "resources"
val mavenTargetDirectory = projectRootDir / "target"
new Directories(
mavenResourcesDirectory / "data",
mavenResourcesDirectory / "bodies",
mavenTargetDirectory / "test-classes",
mavenTargetDirectory / "results")
}
}
开发者ID:rvansa,项目名称:keycloak-benchmark,代码行数:59,代码来源:IDEPathHelper.scala
示例3: S3
//设置package包名称以及导入依赖的类
package com.sample.lambda
import java.io.File
import java.nio.file.{Files, StandardCopyOption}
import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.lambda.runtime.events.S3Event
import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.s3.model.{CannedAccessControlList, ObjectMetadata, PutObjectRequest}
import com.typesafe.config.ConfigFactory
import org.im4java.core.{ConvertCmd, IMOperation}
class S3 {
def handler(event: S3Event, context: Context): String = {
val config = ConfigFactory.load()
val record = event.getRecords.get(0)
val bucket = record.getS3.getBucket.getName
val key = record.getS3.getObject.getKey
val pattern = """(.+)\.(.+)""".r
val patternThumbnail = """(.+)_thumbnail\.(.+)""".r
key match {
case patternThumbnail(name, format) => {
}
case pattern(name, format) => {
val client = new AmazonS3Client()
val s3Object = client.getObject(bucket, key)
val inMetadata = s3Object.getObjectMetadata
val input = s3Object.getObjectContent
val inputFile = File.createTempFile("s3handler", "input")
Files.copy(input, inputFile.toPath(), StandardCopyOption.REPLACE_EXISTING)
val resizedImage = File.createTempFile("s3handler", "resizedImage")
val op = new IMOperation()
op.addImage(inputFile.getAbsolutePath)
op.resize(config.getInt("resized.width"), config.getInt("resized.height"))
op.addImage(resizedImage.getAbsolutePath)
val converter = new ConvertCmd()
converter.run(op)
val resizedKey = name + "_thumbnail." + format
val putObjectRequest = new PutObjectRequest(bucket, resizedKey, resizedImage)
val resizedImageMetadata = new ObjectMetadata()
resizedImageMetadata.setContentType(inMetadata.getContentType)
putObjectRequest.withCannedAcl(CannedAccessControlList.PublicRead).withMetadata(resizedImageMetadata)
client.putObject(putObjectRequest)
}
}
key
}
}
开发者ID:phji,项目名称:lambda-resize-s3-image,代码行数:61,代码来源:S3.scala
注:本文中的java.nio.file.StandardCopyOption类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论