@Override
    public HttpResponseOutputStream<Metadata> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
        try {
            final DbxUserFilesRequests files = new DbxUserFilesRequests(session.getClient(file));
            final UploadSessionStartUploader start = files.uploadSessionStart();
            new DefaultStreamCloser().close(start.getOutputStream());
            final String sessionId = start.finish().getSessionId();
            if(log.isDebugEnabled()) {
                log.debug(String.format("Obtained session id %s for upload %s", sessionId, file));
            }
            final UploadSessionAppendV2Uploader uploader = open(files, sessionId, 0L);
            return new SegmentingUploadProxyOutputStream(file, status, files, uploader, sessionId);
        }
        catch(DbxException ex) {
            throw new DropboxExceptionMappingService().map("Upload failed.", ex, file);
        }
    }
@Test(expected = AccessDeniedException.class)
    public void testWriteLibreOfficeLock() throws Exception {
        final DropboxWriteFeature write = new DropboxWriteFeature(session);
        final TransferStatus status = new TransferStatus();
        final byte[] content = RandomUtils.nextBytes(0);
        status.setLength(content.length);
        final Path test = new Path(new DefaultHomeFinderService(session).find(), ".~lock." + new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file));
        final OutputStream out = write.write(test, status, new DisabledConnectionCallback());
        new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out);
    }