Skip to content

cannot add a file to a directory I own a lock for #397

Answered by Ichicon
abstratt asked this question in Q&A
Discussion options

You must be logged in to vote

Hey it's an old thread but I just had to do the same thing and I found out how by reading some of the webdav RFCs :

For the put method you can do it by adding a If Http header like this :

Map<String, String> headers = new HashMap<>(); 
// fileName is the name of the file at the end of the url
// lockToken has been retrieved when using the lock function
headers.put(HttpHeaders.IF, "<" + fileName + "> (<" + lockToken + ">)");
sardine.put(url, inputStream,  headers);

For the patch method, you'll have to modify the lib to add custom header and do the same thing as put is doing (but with HttpPropPatch instead of HttpPut).

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dkocher
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #250 on June 15, 2023 18:53.