@Override public void run() { container.getFile("a-file.txt", new ObjectTestCallback<File>() { @Override public void onSuccess(File file) { assertEquals("a-file.txt", file.getName()); assertEquals(container.getName(), file.getContainer()); notifyFinished(); } }); } });
/** * Upload a new file * @param file Content of the file. * @param callback The callback to be executed when finished. */ public void upload(java.io.File file, ObjectCallback<File> callback) { getFileRepository().upload(file, callback); }
/** * Name of the container this file belongs to. * @return the container name */ public String getContainer() { return getContainerRef().getName(); }
@Override public void run() { container.upload(fileName, binaryData, null, new ObjectTestCallback<File>() { @Override public void onSuccess(File file) { assertEquals(fileName, file.getName()); notifyFinished(); } }); } });
@Override public void run() { container.getAllFiles(new ListTestCallback<File>() { @Override public void onSuccess(List<File> files) { String[] expectedNames = new String[]{"a-file.txt"}; List<String> actualNames = new ArrayList<String>(); for (File f : files) { actualNames.add(f.getName()); } MoreAsserts.assertEquals(expectedNames, actualNames.toArray()); notifyFinished(); } }); } });
public FileRepository getFileRepository() { RestAdapter adapter = ((RestAdapter)getRepository().getAdapter()); FileRepository repo = adapter.createRepository(FileRepository.class); repo.setContainer(this); return repo; } }
@Override public void run() { container.createFileObject(fileName) .download(new File.DownloadCallback() { @Override public void onSuccess(byte[] content, String contentType) { ref.set(0, content); notifyFinished(); } @Override public void onError(Throwable error) { notifyFailed(error); } }); } });
@Override public void run() { container.upload(name, content, null, new ObjectTestCallback<File>() { @Override public void onSuccess(File object) { ref[0] = object; notifyFinished(); } }); } });
/** * Upload a new file * @param fileName The file name, must be unique within the container. * @param content Content of the file. * @param contentType Content type (optional). * @param callback The callback to be executed when finished. */ public void upload(String fileName, byte[] content, String contentType, ObjectCallback<File> callback) { getFileRepository().upload(fileName, content, contentType, callback); }
@Override public void run() { container.upload(local, new ObjectTestCallback<File>() { @Override public void onSuccess(File file) { assertEquals(local.getName(), file.getName()); notifyFinished(); } }); } });
public String getContainerName() { return getContainer().getName(); }
/** * Create a new File object associated with this container. * @param name The name of the file. * @return the object created */ public File createFileObject(String name) { return getFileRepository().createObject(ImmutableMap.of("name", name)); }
/** * Get data of a File object. * @param fileName The name of the file. * @param callback The callback to be executed when finished. */ public void getFile(String fileName, ObjectCallback<File> callback) { getFileRepository().get(fileName, callback); }
/** * List all files in the container. * @param callback The callback to be executed when finished. */ public void getAllFiles(ListCallback<File> callback) { getFileRepository().getAll(callback); }