当前位置: 首页>>代码示例>>Java>>正文


Java Sardine.setCredentials方法代码示例

本文整理汇总了Java中com.github.sardine.Sardine.setCredentials方法的典型用法代码示例。如果您正苦于以下问题:Java Sardine.setCredentials方法的具体用法?Java Sardine.setCredentials怎么用?Java Sardine.setCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.sardine.Sardine的用法示例。


在下文中一共展示了Sardine.setCredentials方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listFolderContent

import com.github.sardine.Sardine; //导入方法依赖的package包/类
/**
 * List all file names and subfolders of the specified path traversing into subfolders to the given depth.
 *
 * @param path path of the folder
 * @param depth depth of recursion while listing folder contents
 * @return found file names and subfolders
 */
public List<String> listFolderContent(String path, int depth)
{
    String url = (_serverConfig.isUseHTTPS() ? "https" : "http") +"://"+_serverConfig.getServerName()+"/"+WEB_DAV_BASE_PATH+path ;

    List<String> retVal= new LinkedList<>();
    Sardine sardine = SardineFactory.begin();
    sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
    List<DavResource> resources;
    try {
        resources = sardine.list(url, depth);
    } catch (IOException e) {
        throw new NextcloudApiException(e);
    }
    for (DavResource res : resources)
    {
        retVal.add(res.getName());
    }
    return retVal;
}
 
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:27,代码来源:Folders.java

示例2: uploadFile

import com.github.sardine.Sardine; //导入方法依赖的package包/类
/** Uploads a file at the specified path with the data from the InputStream
   *
   * @param inputStream          InputStream of the file which should be uploaded
   * @param remotePath           path where the file should be uploaded to
   */
  public void uploadFile(InputStream inputStream, String remotePath)
  {
  	String path = (_serverConfig.isUseHTTPS() ? "https" : "http") + "://" + _serverConfig.getServerName() + "/" + WEB_DAV_BASE_PATH + remotePath;

Sardine sardine = SardineFactory.begin();

      sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
      sardine.enablePreemptiveAuthentication(_serverConfig.getServerName());

      try {
          sardine.put(path, inputStream);
      } catch (IOException e) {
          throw new NextcloudApiException(e);
      }
  }
 
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:21,代码来源:Files.java

示例3: exists

import com.github.sardine.Sardine; //导入方法依赖的package包/类
/**
 * Checks if the folder at the specified path exists
 *
 * @param rootPath path of the folder
 * @return true if the folder exists
 */
public boolean exists(String rootPath)
{
    String path=  (_serverConfig.isUseHTTPS() ? "https" : "http") +"://"+_serverConfig.getServerName()+"/"+WEB_DAV_BASE_PATH+rootPath ;

    Sardine sardine = SardineFactory.begin();
    sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
    try {
        return sardine.exists(path);
    } catch (IOException e) {
        throw new NextcloudApiException(e);
    }
}
 
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:19,代码来源:Folders.java

示例4: createFolder

import com.github.sardine.Sardine; //导入方法依赖的package包/类
/**
 * Creates a folder at the specified path
 *
 * @param rootPath path of the folder
 */
public void createFolder(String rootPath)
{
    String path=  (_serverConfig.isUseHTTPS() ? "https" : "http") +"://"+_serverConfig.getServerName()+"/"+WEB_DAV_BASE_PATH+rootPath ;

    Sardine sardine = SardineFactory.begin();
    sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
    try {
        sardine.createDirectory(path);
    } catch (IOException e) {
        throw new NextcloudApiException(e);
    }
}
 
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:18,代码来源:Folders.java

示例5: deleteFolder

import com.github.sardine.Sardine; //导入方法依赖的package包/类
/**
 * Deletes the folder at the specified path
 *
 * @param rootPath path of the folder
 */
public void deleteFolder(String rootPath)
{
    String path=  (_serverConfig.isUseHTTPS() ? "https" : "http") +"://"+_serverConfig.getServerName()+"/"+WEB_DAV_BASE_PATH+rootPath ;

    Sardine sardine = SardineFactory.begin();
    sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
    try {
        sardine.delete(path);
    } catch (IOException e) {
        throw new NextcloudApiException(e);
    }
}
 
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:18,代码来源:Folders.java

示例6: fileExists

import com.github.sardine.Sardine; //导入方法依赖的package包/类
/**
 * method to check if a file already exists
 * 
 * @param rootPath path of the file
 * @return boolean value if the given file exists or not
 */
public boolean fileExists(String rootPath){
	String path = (_serverConfig.isUseHTTPS() ? "https" : "http") + "://" + _serverConfig.getServerName() + "/" + WEB_DAV_BASE_PATH + rootPath;
	
	Sardine sardine = SardineFactory.begin();
	
	sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
	sardine.enablePreemptiveAuthentication(_serverConfig.getServerName());
	
	try {
		return sardine.exists(path);
	} catch (IOException e) {
		throw new NextcloudApiException(e);
	}
}
 
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:21,代码来源:Files.java

示例7: removeFile

import com.github.sardine.Sardine; //导入方法依赖的package包/类
/**
 * method to remove files
 * @param rootPath path of the file which should be removed
 */
public void removeFile(String rootPath) {
	String path = (_serverConfig.isUseHTTPS() ? "https" : "http") + "://" + _serverConfig.getServerName() + "/" + WEB_DAV_BASE_PATH + rootPath;
	
	Sardine sardine = SardineFactory.begin();
	
	sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
       sardine.enablePreemptiveAuthentication(_serverConfig.getServerName());
	try {
		sardine.delete(path);
	} catch ( IOException e ) {
		throw new NextcloudApiException(e);
	}
}
 
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:18,代码来源:Files.java


注:本文中的com.github.sardine.Sardine.setCredentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。