- (FMWebDAVRequest*) createDirectory {
if (!_endSelector) {
_endSelector = @selector(requestDidCreateDirectory:);
}
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:_url];
[req setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[req setTimeoutInterval:60 * 5];
[req setHTTPMethod:@"MKCOL"];
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"skipMKCOLContentType"]) {
[req setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
}
[self sendRequest:req];
return self;
我用于iPhone的代码,我为两个平台编写WebDav客户端 但我不知道如何为Android实现MKCOL,这就是我所做的 MKCOL它的WebDav方法创建路径,任何想法?
HttpPut request = new HttpPut();
request.addHeader("", "MKCOL /test879797 HTTP/1.1");
request.addHeader("Host","myserver:port");
request.addHeader("Authorization","Basic YWRtaW46MTIzNDU2");
答案 0 :(得分:3)
使用以下代码:
public class HttpMkCol extends HttpEntityEnclosingRequestBase
{
public static final String METHOD_NAME = "MKCOL";
public HttpMkCol(String url)
{
this(URI.create(url));
}
public HttpMkCol(URI url)
{
this.setURI(url);
}
@Override
public String getMethod()
{
return METHOD_NAME;
}
}
原始来源: https://github.com/lookfirst/sardine HttpMkCol.java
答案 1 :(得分:0)
HttpPut request = new HttpPut();
MKCOL
不是PUT
。
Apache HttpClient不直接支持WebDAV。我们欢迎您尝试创建自己的org.apache.http.message.AbstractHttpMessage
自定义子类来实现MKCOL
动词。
或者,您可以看到其他人是否为Apache HttpClient创建了WebDAV扩展。
或者,您可以找到另一个适用于Java的WebDAV客户端库,看看它是否在Android上运行。