本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}