mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Add method for deleting a file from a mailbox
This commit is contained in:
@@ -88,6 +88,14 @@ interface MailboxApi {
|
||||
void getFile(MailboxProperties properties, String folderId,
|
||||
String fileId, File file) throws IOException, ApiException;
|
||||
|
||||
/**
|
||||
* Used by owner and contacts to delete files.
|
||||
* <p>
|
||||
* Returns 200 OK (no exception) if deletion was successful.
|
||||
*/
|
||||
void deleteFile(MailboxProperties properties, String folderId,
|
||||
String fileId) throws IOException, ApiException;
|
||||
|
||||
@Immutable
|
||||
@JsonSerialize
|
||||
class MailboxContact {
|
||||
|
||||
@@ -221,6 +221,19 @@ class MailboxApiImpl implements MailboxApi {
|
||||
copyAndClose(body.byteStream(), outputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(MailboxProperties properties, String folderId,
|
||||
String fileId) throws IOException, ApiException {
|
||||
String path = "/files/" + folderId + "/" + fileId;
|
||||
Request request = getRequestBuilder(properties.getAuthToken())
|
||||
.delete()
|
||||
.url(properties.getOnionAddress() + path)
|
||||
.build();
|
||||
OkHttpClient client = httpClientProvider.get();
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.code() != 200) throw new ApiException();
|
||||
}
|
||||
|
||||
/* Helper Functions */
|
||||
|
||||
private Response sendGetRequest(MailboxProperties properties, String path)
|
||||
|
||||
Reference in New Issue
Block a user