mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-11-29 18:48:23 +08:00
[Fs] [Amazon S3] Add docs
This commit is contained in:
parent
bca099f476
commit
52c85f4d3c
@ -152,6 +152,13 @@ datacap.fs.bucket=
|
||||
#datacap.fs.endpoint=
|
||||
#datacap.fs.bucket=
|
||||
|
||||
# ------ Amazon S3 File System ------#
|
||||
#datacap.fs.type=AmazonS3
|
||||
#datacap.fs.access=
|
||||
#datacap.fs.secret=
|
||||
#datacap.fs.endpoint=
|
||||
#datacap.fs.bucket=
|
||||
|
||||
################################# Experimental features #################################
|
||||
# This configuration is used to dynamically increase the total number of rows of returned data in SQL during query, and currently only takes effect for user-directed queries
|
||||
# If the total number of rows returned is included in the SQL, it will not be automatically incremented
|
||||
|
@ -10,7 +10,6 @@
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-common</artifactId>
|
||||
<description>DataCap - common</description>
|
||||
|
||||
|
@ -25,6 +25,21 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<version>${springboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
|
134
docs/docs/reference/filesystem/s3/home.md
Normal file
134
docs/docs/reference/filesystem/s3/home.md
Normal file
@ -0,0 +1,134 @@
|
||||
---
|
||||
title: 亚马逊云 S3
|
||||
---
|
||||
|
||||
在 DataCap 中目前已经支持亚马逊云 S3,支持功能如下:
|
||||
|
||||
- 上传文件
|
||||
- 预览&下载文件
|
||||
- 删除文件
|
||||
|
||||
### DataCap 使用配置
|
||||
|
||||
---
|
||||
|
||||
在 DataCap 中文件系统用于配置系统的缓冲以及临时文件的存储。修改 `application.properties` 文件如下内容:
|
||||
|
||||
```properties
|
||||
datacap.fs.type=AmazonS3
|
||||
datacap.fs.access=
|
||||
datacap.fs.secret=
|
||||
datacap.fs.endpoint=
|
||||
datacap.fs.bucket=
|
||||
```
|
||||
|
||||
- `datacap.fs.type`: 文件系统的类型只能是 **AmazonS3**
|
||||
- `datacap.fs.access`: 亚马逊云的 AccessKey
|
||||
- `datacap.fs.secret`: 亚马逊云的 SecretKey
|
||||
- `datacap.fs.endpoint`: 亚马逊云的 Endpoint,如 `cn-north-1`,不需要输入整个的地址
|
||||
- `datacap.fs.bucket`: 亚马逊云的存储桶名称,如 `datacap`
|
||||
|
||||
### 依赖使用方式
|
||||
|
||||
---
|
||||
|
||||
该插件支持第三方依赖方式引入,引入依赖如下:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-fs-amazon-s3</artifactId>
|
||||
<version>${VERSION}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
使用代码如下:
|
||||
|
||||
```kotlin
|
||||
package io.edurt.datacap.fs.s3
|
||||
|
||||
import com.google.inject.Guice
|
||||
import com.google.inject.Injector
|
||||
import com.google.inject.Key
|
||||
import com.google.inject.TypeLiteral
|
||||
import io.edurt.datacap.fs.Fs
|
||||
import io.edurt.datacap.fs.FsManager
|
||||
import io.edurt.datacap.fs.FsRequest
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.BufferedReader
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
class AmazonS3FsTest
|
||||
{
|
||||
private val log = LoggerFactory.getLogger(AmazonS3FsTest::class.java)
|
||||
private val name = "AmazonS3"
|
||||
private var request = FsRequest()
|
||||
private var injector: Injector? = null
|
||||
|
||||
@Before
|
||||
fun before()
|
||||
{
|
||||
request.access = System.getProperty("access")
|
||||
request.secret = System.getProperty("secret")
|
||||
request.bucket = System.getProperty("bucket")
|
||||
request.fileName = "TencentCosFsTest.kt"
|
||||
request.endpoint = System.getProperty("endpoint")
|
||||
|
||||
injector = Guice.createInjector(FsManager())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun writer()
|
||||
{
|
||||
val plugins: Set<Fs?>? = injector?.getInstance(Key.get(object : TypeLiteral<Set<Fs?>?>()
|
||||
{}))
|
||||
val plugin: Fs? = plugins?.first { v -> v?.name().equals(name) }
|
||||
|
||||
val stream = FileInputStream("src/test/kotlin/io/edurt/datacap/fs/s3/AmazonS3FsTest.kt")
|
||||
request.stream = stream
|
||||
val response = plugin !!.writer(request)
|
||||
assertTrue(response.isSuccessful)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun reader()
|
||||
{
|
||||
val plugins: Set<Fs?>? = injector?.getInstance(Key.get(object : TypeLiteral<Set<Fs?>?>()
|
||||
{}))
|
||||
val plugin: Fs? = plugins?.first { v -> v?.name().equals(name) }
|
||||
val response = plugin !!.reader(request)
|
||||
assertTrue(response.isSuccessful)
|
||||
|
||||
try
|
||||
{
|
||||
BufferedReader(InputStreamReader(response.context, StandardCharsets.UTF_8)).use { reader ->
|
||||
var line: String?
|
||||
while ((reader.readLine().also { line = it }) != null)
|
||||
{
|
||||
log.info(line)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: IOException)
|
||||
{
|
||||
log.error("Reader error", e)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun delete()
|
||||
{
|
||||
val plugins: Set<Fs?>? = injector?.getInstance(Key.get(object : TypeLiteral<Set<Fs?>?>()
|
||||
{}))
|
||||
val plugin: Fs? = plugins?.first { v -> v?.name().equals(name) }
|
||||
val response = plugin !!.delete(request)
|
||||
assertTrue(response.isSuccessful)
|
||||
}
|
||||
}
|
||||
```
|
@ -222,6 +222,7 @@ nav:
|
||||
- reference/filesystem/aliyun/home.md
|
||||
- reference/filesystem/qiniu/home.md
|
||||
- reference/filesystem/cos/home.md
|
||||
- reference/filesystem/s3/home.md
|
||||
- NavReleaseNote:
|
||||
- 2024.03.8 (latest): release/latest.md
|
||||
- 2024.03.7: release/2024.03.7.md
|
||||
|
Loading…
Reference in New Issue
Block a user