Code Monkey home page Code Monkey logo

webdav-spring-boot-starter's Introduction

Maven Central GitHub license Build Status

使用SpringBoot-Starter机制,基于jackrabbit-webdav打造的webdav-cleint,基于apache2的webdav模块测试,也可以使用其他webdav协议。

提前安装httpd服务器设置指定目录,Httpd操作封装,包括文件上传下载,检测文件是否存在等操作。具体使用见测试类和文档。

使用Maven依赖:

<dependency>
    <groupId>io.github.lunasaw</groupId>
    <artifactId>webdav-spring-boot-starter</artifactId>
    <version>${latest.version}</version>
</dependency>

Api文档链接

webdav-spring-boot-starter使用示例:

1.引入依赖

2.添加配置

指定spring.webdav.host后,spring启动会自动引入io.github.lunasaw.webdav.config.WebDavAutoConfiguration初始化配置。

spring:
  webdav:
    host: http://127.0.0.1:8080 #指定host
    path: /webdav/project #指定跟路径
    scope: luna #指定项目scope 可选,后续上传可自定义scpoe
    maxTotal: 80 # 最大链接数量通 优化httpclient
    defaultMaxPerRoute: 100
    username: luna # webdav 的basic配置用户名
    password: luna # webdav 的basic配置密码
    auth-type: digest # webdav 认证类型,可选basic,digest,暂不支持:ntlm,kerberos,spnego,negotiate
    openLog: true # 是否开启日志 默认false 开启会打印每次返回的response

3.使用

所有方法都封装在io.github.lunasaw.webdav.request.WebDavBaseUtils使用可以参见webdav-spring-boot-starter-test,只需要注入即可使用,详细使用可见io.github.lunasaw.WebDavTest

下面是部分例子

@Autowired
private WebDavUtils webDavUtils;

SCOPE_PATH 使用前置测试方法,先获取到SCOPE_PATH,按照上述配置则为 http://127.0.0.1:8080/webdav/project/luna

@Before public void pre() { SCOPE_PATH = webDavSupport.getScopePath(); }

上传

下载test模块resource下附带一个测试图片,引用上述配置后,webDavUtils.upload(IMAGE, file.getAbsolutePath())上传文件,即可在http://127.0.0.1:8080/webdav/project/luna/IMAGE 下看到所需文件。

@Test
public void a_upload_test() throws FileNotFoundException {
    File file = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX + IMAGE);
    Assert.isTrue(webDavUtils.upload(IMAGE, file.getAbsolutePath()));
    Assert.isTrue(webDavUtils.exist(SCOPE_PATH + IMAGE));
}

下载

下载同理,测试将文件刚刚上传的文件下载到本地目录。webDavUtils.download(SCOPE_PATH + IMAGE, localPath);即可

@Test
public void download_test() {
    String localPath = FileTools.getUserHomePath() + "/buy_logo_{}.jpeg";
    localPath = StringTools.format(localPath, RandomUtils.nextInt());
    webDavUtils.download(SCOPE_PATH + IMAGE, localPath);
    Assert.isTrue(FileTools.isExists(localPath), localPath + "文件下载错误");
    FileTools.deleteIfExists(localPath);
}

其他使用见io.github.lunasaw.webdav.request.WebDavJackrabbitUtils

webdav-spring-boot-starter's People

Contributors

lunasaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webdav-spring-boot-starter's Issues

对Jackrabbit WebDAV的疑问

请问,Jackrabbit对WebDAV是只支持增删改查的是吗

Jackrabbit有没有能够作为webDAV服务器的功能,我看到里面有个AbstractWebdavServlet抽象类。但没有细读下去,请问是否有这个功能,或者有没有用java实现webDAV服务器,并且可以进行挂载的项目。就是不需要再额外安装httpd就可以运行的。

功能预览

  1. 其他方式登陆验证
  2. READEM.md 更新
  3. code doc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.