/** * Resizes the file to the specified size. * * @param size * A <code>long</code> which represents the size of the file, in bytes. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException */ public void resize(long size) throws StorageException, URISyntaxException { this.resize(size, null /* accessCondition */, null /* options */, null /* operationContext */); }
/** * Resizes the file to the specified size. * * @param size * A <code>long</code> which represents the size of the file, in bytes. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException */ public void resize(long size) throws StorageException, URISyntaxException { this.resize(size, null /* accessCondition */, null /* options */, null /* operationContext */); }
/** * Test file resizing. * * @throws URISyntaxException * @throws StorageException */ @Test public void testCloudFileResize() throws URISyntaxException, StorageException { CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1"); CloudFile file2 = this.share.getRootDirectoryReference().getFileReference("file1"); file.create(1024); assertEquals(1024, file.getProperties().getLength()); file2.downloadAttributes(); assertEquals(1024, file2.getProperties().getLength()); file2.getProperties().setContentType("text/plain"); file2.uploadProperties(); file.resize(2048); assertEquals(2048, file.getProperties().getLength()); file.downloadAttributes(); assertEquals("text/plain", file.getProperties().getContentType()); file2.downloadAttributes(); assertEquals(2048, file2.getProperties().getLength()); // Resize to 0 length file.resize(0); assertEquals(0, file.getProperties().getLength()); file.downloadAttributes(); assertEquals("text/plain", file.getProperties().getContentType()); file2.downloadAttributes(); assertEquals(0, file2.getProperties().getLength()); }
/** * Test file resizing. * * @throws URISyntaxException * @throws StorageException */ @Test public void testCloudFileResize2() throws StorageException, URISyntaxException { CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1"); CloudFile file2 = this.share.getRootDirectoryReference().getFileReference("file1"); file.create(1024); assertEquals(1024, file.getProperties().getLength()); file2.downloadAttributes(); assertEquals(1024, file2.getProperties().getLength()); file2.getProperties().setContentType("text/plain"); file2.uploadProperties(); file.resize(2048); assertEquals(2048, file.getProperties().getLength()); file.downloadAttributes(); assertEquals("text/plain", file.getProperties().getContentType()); file2.downloadAttributes(); assertEquals(2048, file2.getProperties().getLength()); }