Atitit webdav大文件上传的解决方案
目录
Upload file thro webdav client java api
解决方法,可以修改本地电脑注册表:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters
找到FileSizeLimitInBytes值,修改其十进制为:4294967295
再重新在sharepoint 的文档库或者资产库等列表,使用资源管理器打开,就能把大文件copy出来了(还不行重启电脑吧)
webDAV
在某些版本的Windows 操作系统中,WebDAV 驱动器的最大文件大小被限制为 50MB。如果你试图复制超过 50MB 大小的文件,Windows 就会弹出错误提示框。
当然,这个限制是可以通过修改注册表来消除的。将注册表中位于
HKLM\SYSTEM\CurrentControlSet\Services\WebClient\Parameters\FileSizeLimitInBytes 处的键值由 50,000,000 (50MB) 修改为更大的数值。建议修改后重启电脑再尝试拷贝。
修改了注册表,重启了webclient服务,貌似依然不行。。在资源管理器。。
package webdavclient;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URI;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.StatusLine;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.jackrabbit.webdav.client.methods.CopyMethod;
import org.apache.jackrabbit.webdav.client.methods.DavMethod;
import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
import org.apache.jackrabbit.webdav.client.methods.PutMethod;
// /webdavclient/src/webdavclient/webdavclientUtil.java
public class webdavclientUtil {
public static void main(String[] args) throws HttpException, IOException {
//jackrabbit ver 2.6.10
HttpClient HttpClient1 = new HttpClient(); //HttpClient 3.1 jar
Credentials creds = new UsernamePasswordCredentials("admin", "password");
//client.getState().setCredentials(AuthScope.ANY, creds);
// MKCOL method mk dir foler
DavMethod mkCol = new MkColMethod("http://192.168.1.77:1316/webdavapp/webdavurl/tests67");
HttpClient1.executeMethod(mkCol);
int statusCode = mkCol.getStatusCode();
String statusText = mkCol.getStatusText();
StatusLine statusLine = mkCol.getStatusLine();
System.out.println("d");
String rar="C:\\d\\dockbase\\jdk1.8.0_131.rar";
URI uri = new File(rar).toURI();
String destinationUri="http://192.168.1.77:1316/webdavapp/webdavurl/tests67/jdk1.8.0_131.rar.zip";
//copyMethod:复制一个资源从服务器上的一个位置到另一个位置
//CopyMethod CopyMethod1=new CopyMethod(uri.toString(), destinationUri, true); // unsupported protocol: 'file'
PutMethod putMethod1=new PutMethod(destinationUri.toString());
RequestEntity requestEntity = new InputStreamRequestEntity(
new FileInputStream(rar));
putMethod1.setRequestEntity(requestEntity);
HttpClient1.executeMethod(putMethod1);
StatusLine statusLine_CopyMethod1 = putMethod1.getStatusLine();
System.out.println("d2");
}
}
使用Apache Jackrabbit实现 WebDAV 客户端.html
Java_ How to upload a file to a WebDAV server from a servlet_ - Stack Overflow.html
�S�����