private void create() throws StorageException, URISyntaxException { this.fileShare.createIfNotExists(); //TODO: create method must provide file length, but we don't know actual //file size when creating. Pending on github issue feedback. this.cloudFile.create(1024); } }
@Override public void setHeaders(HttpURLConnection connection, CloudFileDirectory directory, OperationContext context) { FileRequest.addMetadata(connection, directory.getMetadata(), context); }
@Override public String preProcessResponse(CloudFile file, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); return null; } file.updateEtagAndLastModifiedFromResponse(this.getConnection()); file.properties.setCopyState(FileResponse.getCopyState(this.getConnection())); return file.properties.getCopyState().getCopyId(); } };
public static void setFileProperties(CloudFile file) { file.getProperties().setCacheControl("no-transform"); file.getProperties().setContentDisposition("attachment"); file.getProperties().setContentEncoding("gzip"); file.getProperties().setContentLanguage("tr,en"); file.getProperties().setContentMD5("MDAwMDAwMDA="); file.getProperties().setContentType("text/html"); } }
@Before public void fileEncryptionTestMethodSetup() throws URISyntaxException, StorageException, IOException { this.share = FileTestHelper.getRandomShareReference(); this.share.create(); this.dir = this.share.getRootDirectoryReference().getDirectoryReference("dir"); this.dir.create(); this.file = this.share.getRootDirectoryReference().getFileReference("file"); this.file.uploadText("text"); }
public static CloudFile defiddler(CloudFile file) throws URISyntaxException, StorageException { URI oldUri = file.getUri(); URI newUri = defiddler(oldUri); if (newUri != oldUri) { CloudFile newFile = new CloudFile(newUri, file.getServiceClient().getCredentials()); return newFile; } else { return file; } }
public static CloudFile uploadNewFile( CloudFileShare share, InputStream stream, int length, OperationContext context) throws StorageException, IOException, URISyntaxException { String name = generateRandomFileName(); CloudFile file = null; file = share.getRootDirectoryReference().getFileReference(name); file.upload(stream, length, null, null, context); return file; }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.getFileProperties( file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition, file.getShare().snapshotID); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.getFileRanges(file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition, file.getShare().snapshotID); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.getFileProperties( file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition, file.getShare().snapshotID); }
@Override public ArrayList<FileRange> postProcessResponse(HttpURLConnection connection, CloudFile file, CloudFileClient client, OperationContext context, ArrayList<FileRange> storageObject) throws Exception { file.updateEtagAndLastModifiedFromResponse(this.getConnection()); file.updateLengthFromResponse(this.getConnection()); return FileRangeHandler.getFileRanges(this.getConnection().getInputStream()); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFileDirectory directory, OperationContext context) throws Exception { return FileRequest.getDirectoryProperties( directory.getTransformedAddress().getUri(this.getCurrentLocation()), options, context, accessCondition, directory.getShare().snapshotID); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFileDirectory directory, OperationContext context) throws Exception { return FileRequest.getDirectoryProperties( directory.getTransformedAddress().getUri(this.getCurrentLocation()), options, context, accessCondition, directory.getShare().snapshotID); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.abortCopy(file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition, copyId); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.putFile(file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition, file.properties, size); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.setFileProperties( file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition, file.properties); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.deleteFile(file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.setFileMetadata( file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition); }
@Override public String preProcessResponse(CloudFile file, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); return null; } file.updateEtagAndLastModifiedFromResponse(this.getConnection()); file.properties.setCopyState(FileResponse.getCopyState(this.getConnection())); return file.properties.getCopyState().getCopyId(); } };
@Override public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context) throws Exception { return FileRequest.getFileProperties( file.getTransformedAddress(context).getUri(this.getCurrentLocation()), options, context, accessCondition, file.getShare().snapshotID); }