static BaasResult<BaasStream> doStreamSync(String id, String spec, int sizeId) { BaasBox box = BaasBox.getDefaultChecked(); if (id == null) throw new IllegalArgumentException("id cannot be null"); StreamRequest synReq = new StreamRequest(box, "asset", id, spec, sizeId); return box.submitSync(synReq); }
static <R> RequestToken doStreamAsset( String name, String sizeSpec, int sizeIdx, int priority, DataStreamHandler<R> dataStreamHandler, BaasHandler<R> handler) { BaasBox box = BaasBox.getDefaultChecked(); if (dataStreamHandler == null) throw new IllegalArgumentException("data handler cannot be null"); if (name == null) throw new IllegalArgumentException("id cannot be null"); AsyncStream<R> stream = new AssetStream<R>(box, name, sizeSpec, sizeIdx, priority, dataStreamHandler, handler); return box.submitAsync(stream); }
/** * Synchronously retrieves named assets data, If the named asset is a document, the document is * retrieved otherwise attached data to the file are returned. * * @param id the name of the asset * @return a baas result wrapping the response. */ public static BaasResult<JsonObject> fetchDataSync(String id) { if (id == null) throw new IllegalArgumentException("asset id cannot be null"); BaasBox box = BaasBox.getDefaultChecked(); AssetDataRequest req = new AssetDataRequest(box, id, RequestOptions.DEFAULT, null); return box.submitSync(req); }
/** * Asynchronously retrieves named assets data, If the named asset is a document, the document is * retrieved otherwise attached data to the file are returned. * * @param id the name of the asset * @param flags used for the request a bit or of {@link RequestOptions} constants * @param handler an handler that will be handed the response * @return a request token */ public static RequestToken fetchData(String id, int flags, BaasHandler<JsonObject> handler) { if (id == null) throw new IllegalArgumentException("asset id cannot be null"); BaasBox box = BaasBox.getDefaultChecked(); AssetDataRequest req = new AssetDataRequest(box, id, flags, handler); return box.submitAsync(req); }