com.cloudinary.utils.ObjectUtils Java Examples
The following examples show how to use
com.cloudinary.utils.ObjectUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UploaderTest.java From cloudinary_android with MIT License | 6 votes |
@Test public void testUploadDataUri() throws Exception { if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject( cloudinary .uploader() .upload("data:image/png;base64,iVBORw0KGgoAA\nAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0l\nEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6\nP9/AFGGFyjOXZtQAAAAAElFTkSuQmCC", ObjectUtils.emptyMap())); Assert.assertEquals(result.getLong("width"), 16L); Assert.assertEquals(result.getLong("height"), 16L); Map<String, Object> to_sign = new HashMap<String, Object>(); to_sign.put("public_id", (String) result.get("public_id")); to_sign.put("version", ObjectUtils.asString(result.get("version"))); String expected_signature = cloudinary.apiSignRequest(to_sign, cloudinary.config.apiSecret); Assert.assertEquals(result.get("signature"), expected_signature); }
Example #2
Source File: UploaderTest.java From cloudinary_android with MIT License | 6 votes |
@Test public void testRename() throws Exception { if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.emptyMap())); cloudinary.uploader().rename(result.getString("public_id"), result.get("public_id") + "2", ObjectUtils.emptyMap()); JSONObject result2 = new JSONObject(cloudinary.uploader().upload(getAssetStream("images/favicon.ico"), ObjectUtils.emptyMap())); boolean error_found = false; try { cloudinary.uploader().rename((String) result2.get("public_id"), result.get("public_id") + "2", ObjectUtils.emptyMap()); } catch (Exception e) { error_found = true; } assertTrue(error_found); cloudinary.uploader().rename((String) result2.get("public_id"), result.get("public_id") + "2", ObjectUtils.asMap("overwrite", Boolean.TRUE)); }
Example #3
Source File: UploaderTest.java From cloudinary_android with MIT License | 6 votes |
@Test public void testUniqueFilename() throws Exception { if (cloudinary.config.apiSecret == null) return; File f = new File(InstrumentationRegistry.getInstrumentation().getContext().getCacheDir() + "/old_logo.png"); InputStream is = getAssetStream(TEST_IMAGE); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); FileOutputStream fos = new FileOutputStream(f); fos.write(buffer); fos.close(); JSONObject result = new JSONObject(cloudinary.uploader().upload(f, ObjectUtils.asMap("use_filename", true))); assertTrue(result.getString("public_id").matches("old_logo_[a-z0-9]{6}")); result = new JSONObject(cloudinary.uploader().upload(f, ObjectUtils.asMap("use_filename", true, "unique_filename", false))); Assert.assertEquals(result.getString("public_id"), "old_logo"); }
Example #4
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testSprite() throws Exception { if (cloudinary.config.apiSecret == null) return; final String sprite_test_tag = String.format("sprite_test_tag_%d", new java.util.Date().getTime()); cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("tags", sprite_test_tag, "public_id", "sprite_test_tag_1")); cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("tags", sprite_test_tag, "public_id", "sprite_test_tag_2")); JSONObject result = new JSONObject(cloudinary.uploader().generateSprite(sprite_test_tag, ObjectUtils.emptyMap())); Assert.assertEquals(2, result.getJSONObject("image_infos").length()); result = new JSONObject(cloudinary.uploader().generateSprite(sprite_test_tag, ObjectUtils.asMap("transformation", "w_100"))); assertTrue((result.getString("css_url")).contains("w_100")); result = new JSONObject(cloudinary.uploader().generateSprite(sprite_test_tag, ObjectUtils.asMap("transformation", new Transformation().width(100), "format", "jpg"))); assertTrue((result.getString("css_url")).contains("f_jpg,w_100")); }
Example #5
Source File: UtilsTest.java From cloudinary_android with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Test public void testOptionsSerialization() throws IOException, ClassNotFoundException { Map<String, Object> options = new HashMap<>(); options.put("integer", 12); options.put("string", "twelve"); options.put("transformation", new Transformation().angle(30)); options.put("array", new int[]{1, 2, 3}); Map<String, Object> newMap = (Map<String, Object>) ObjectUtils.deserialize(ObjectUtils.serialize(options)); assertEquals(12, newMap.get("integer")); assertEquals("twelve", newMap.get("string")); Assert.assertEquals(new Transformation().angle(30).generate(), ((Transformation) newMap.get("transformation")).generate()); assertTrue(Arrays.equals(new int[]{1, 2, 3}, (int[]) newMap.get("array"))); }
Example #6
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testUploadLargeProgressCallback() throws Exception { // support uploading large files if (cloudinary.config.apiSecret == null) return; File temp = getLargeFile(); final CountDownLatch signal = new CountDownLatch(1); final long totalLength = temp.length(); ProgressCallback progressCallback = new ProgressCallback() { @Override public void onProgress(long bytesUploaded, long totalBytes) { if (bytesUploaded == totalLength) { signal.countDown(); } } }; JSONObject resource = new JSONObject(cloudinary.uploader().uploadLarge(temp, ObjectUtils.asMap("resource_type", "raw", "chunk_size", 5243000), progressCallback)); signal.await(120, TimeUnit.SECONDS); assertEquals(signal.getCount(), 0); Assert.assertEquals("raw", resource.getString("resource_type")); resource = new JSONObject(cloudinary.uploader().uploadLarge(temp, ObjectUtils.asMap("chunk_size", 5243000))); Assert.assertEquals("image", resource.getString("resource_type")); Assert.assertEquals(1400L, resource.getLong("width")); Assert.assertEquals(1400L, resource.getLong("height")); resource = new JSONObject(cloudinary.uploader().uploadLarge(temp, ObjectUtils.asMap("chunk_size", 5880138))); Assert.assertEquals("image", resource.getString("resource_type")); Assert.assertEquals(1400L, resource.getLong("width")); Assert.assertEquals(1400L, resource.getLong("height")); }
Example #7
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void testUploadLarge() throws Exception { // support uploading large files if (cloudinary.config.apiSecret == null) return; File temp = File.createTempFile("cldupload.test.", ""); FileOutputStream out = new FileOutputStream(temp); int[] header = new int[]{0x42, 0x4D, 0x4A, 0xB9, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x78, 0x05, 0x00, 0x00, 0x78, 0x05, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xB8, 0x59, 0x00, 0x61, 0x0F, 0x00, 0x00, 0x61, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0xB8, 0x1E, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC4, 0xF5, 0x28, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; byte[] byteHeader = new byte[138]; for (int i = 0; i <= 137; i++) byteHeader[i] = (byte) header[i]; byte[] piece = new byte[10]; Arrays.fill(piece, (byte) 0xff); out.write(byteHeader); for (int i = 1; i <= 588000; i++) { out.write(piece); } out.close(); assertEquals(5880138, temp.length()); JSONObject resource = new JSONObject(cloudinary.uploader().uploadLarge(temp, ObjectUtils.asMap("resource_type", "raw", "chunk_size", 5243000))); Assert.assertEquals("raw", resource.getString("resource_type")); resource = new JSONObject(cloudinary.uploader().uploadLarge(temp, ObjectUtils.asMap("chunk_size", 5243000))); Assert.assertEquals("image", resource.getString("resource_type")); Assert.assertEquals(1400L, resource.getLong("width")); Assert.assertEquals(1400L, resource.getLong("height")); resource = new JSONObject(cloudinary.uploader().uploadLarge(temp, ObjectUtils.asMap("chunk_size", 5880138))); Assert.assertEquals("image", resource.getString("resource_type")); Assert.assertEquals(1400L, resource.getLong("width")); Assert.assertEquals(1400L, resource.getLong("height")); }
Example #8
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testComplexFilenameOption() throws Exception { String complexFilename = "Universal Image Loader @#&=+-_.,!()~'%20.png"; JSONObject result = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("filename", complexFilename))); complexFilename = complexFilename.replace(".png", ""); Assert.assertEquals(complexFilename, result.getString("original_filename")); }
Example #9
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testDetectionRequest() { // should support requesting detection if (cloudinary.config.apiSecret == null) return; try { cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("detection", "illegal")); } catch (Exception e) { assertTrue(e.getMessage().matches(".*(Illegal value|not a valid|invalid).*")); } }
Example #10
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testCategorizationRequest() { String errorMessage = ""; // should support requesting categorization if (cloudinary.config.apiSecret == null) return; try { cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("categorization", "illegal")); } catch (Exception e) { errorMessage = e.getMessage(); } assertTrue(errorMessage.contains("Categorization item illegal is not valid")); }
Example #11
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testRawConvertRequest() { // should support requesting raw conversion if (cloudinary.config.apiSecret == null) return; try { cloudinary.uploader().upload(getAssetStream("docx.docx"), ObjectUtils.asMap("raw_convert", "illegal", "resource_type", "raw")); } catch (Exception e) { assertEquals("Raw convert is invalid", e.getMessage()); } }
Example #12
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testModerationRequest() throws Exception { // should support requesting manual moderation if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("moderation", "manual"))); Assert.assertEquals("manual", result.getJSONArray("moderation").getJSONObject(0).getString("kind")); Assert.assertEquals("pending", result.getJSONArray("moderation").getJSONObject(0).getString("status")); }
Example #13
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testContext() throws Exception { // should allow sending context if (cloudinary.config.apiSecret == null) return; @SuppressWarnings("rawtypes") Map context = ObjectUtils.asMap("caption", "some caption", "alt", "alternative"); cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("context", context)); }
Example #14
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testFaceCoordinates() throws Exception { // should allow sending face coordinates if (cloudinary.config.apiSecret == null) return; Coordinates coordinates = new Coordinates(); Rectangle rect1 = new Rectangle(121, 31, 110, 51); Rectangle rect2 = new Rectangle(120, 30, 109, 51); coordinates.addRect(rect1); coordinates.addRect(rect2); JSONObject result = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("face_coordinates", coordinates, "faces", true))); JSONArray resultFaces = result.getJSONArray("faces"); Assert.assertEquals(2, resultFaces.length()); JSONArray resultCoordinates = resultFaces.getJSONArray(0); Assert.assertEquals(rect1.x, resultCoordinates.getInt(0)); Assert.assertEquals(rect1.y, resultCoordinates.getInt(1)); Assert.assertEquals(rect1.width, resultCoordinates.getInt(2)); Assert.assertEquals(rect1.height, resultCoordinates.getInt(3)); resultCoordinates = resultFaces.getJSONArray(1); Assert.assertEquals(rect2.x, resultCoordinates.getInt(0)); Assert.assertEquals(rect2.y, resultCoordinates.getInt(1)); Assert.assertEquals(rect2.width, resultCoordinates.getInt(2)); Assert.assertEquals(rect2.height, resultCoordinates.getInt(3)); }
Example #15
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testMulti() throws Exception { if (cloudinary.config.apiSecret == null) return; cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("tags", "multi_test_tag", "public_id", "multi_test_tag_1")); cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("tags", "multi_test_tag", "public_id", "multi_test_tag_2")); JSONObject result = new JSONObject(cloudinary.uploader().multi("multi_test_tag", ObjectUtils.emptyMap())); assertTrue((result.getString("url")).endsWith(".gif")); result = new JSONObject(cloudinary.uploader().multi("multi_test_tag", ObjectUtils.asMap("transformation", "w_100"))); assertTrue((result.getString("url")).contains("w_100")); result = new JSONObject(cloudinary.uploader().multi("multi_test_tag", ObjectUtils.asMap("transformation", new Transformation().width(111), "format", "pdf"))); assertTrue((result.getString("url")).contains("w_111")); assertTrue((result.getString("url")).endsWith(".pdf")); }
Example #16
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testUploadProgressCallback() throws Exception { if (cloudinary.config.apiSecret == null) return; final long totalLength = getAssetFileSize(TEST_IMAGE); final long[] totalUploaded = new long[]{0}; ProgressCallback progressCallback = new ProgressCallback() { @Override public void onProgress(long bytesUploaded, long totalBytes) { totalUploaded[0] += bytesUploaded; } }; JSONObject result = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("colors", true), progressCallback)); assertTrue("ProgressCallback was never called", totalUploaded[0] > 0); assertEquals("ProgressCallback calls do not sum up to actual file length", totalLength, totalUploaded[0]); Assert.assertEquals(result.getLong("width"), 241L); Assert.assertEquals(result.getLong("height"), 51L); assertNotNull(result.get("colors")); assertNotNull(result.get("predominant")); Map<String, Object> to_sign = new HashMap<String, Object>(); to_sign.put("public_id", result.getString("public_id")); to_sign.put("version", ObjectUtils.asString(result.get("version"))); String expected_signature = cloudinary.apiSignRequest(to_sign, cloudinary.config.apiSecret); Assert.assertEquals(result.get("signature"), expected_signature); }
Example #17
Source File: OrderManager.java From Pharmacy-Android with GNU General Public License v3.0 | 5 votes |
/** * Deletes image on the given id * @implNote Run it on other than MainThread * @param publicId * @return void */ public static Observable<Void> deleteImage(String publicId) { return Observable.create(subscriber -> { try { Cloudinary cloudinary = Utils.getCloudinary(); cloudinary.uploader().destroy(publicId, ObjectUtils.emptyMap()); Timber.i("Image deleted, id: %s", publicId); subscriber.onCompleted(); } catch (IOException e) { Timber.e(e, "Image delete error, id: %s", publicId); e.printStackTrace(); subscriber.onError(e); } }); }
Example #18
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testUpload() throws Exception { if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("colors", true))); Assert.assertEquals(result.getLong("width"), 241L); Assert.assertEquals(result.getLong("height"), 51L); assertNotNull(result.get("colors")); assertNotNull(result.get("predominant")); Map<String, Object> to_sign = new HashMap<String, Object>(); to_sign.put("public_id", result.getString("public_id")); to_sign.put("version", ObjectUtils.asString(result.get("version"))); String expected_signature = cloudinary.apiSignRequest(to_sign, cloudinary.config.apiSecret); Assert.assertEquals(result.get("signature"), expected_signature); }
Example #19
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testText() throws Exception { if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject(cloudinary.uploader().text("hello world", ObjectUtils.emptyMap())); assertTrue(result.getInt("width") > 1); assertTrue(result.getInt("height") > 1); }
Example #20
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testUnsignedUpload() throws Exception { if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject(cloudinary.uploader().unsignedUpload(getAssetStream(TEST_IMAGE), TEST_PRESET, ObjectUtils.emptyMap())); Assert.assertEquals(result.getLong("width"), 241L); Assert.assertEquals(result.getLong("height"), 51L); Map<String, Object> to_sign = new HashMap<String, Object>(); to_sign.put("public_id", result.getString("public_id")); to_sign.put("version", ObjectUtils.asString(result.get("version"))); Log.d("TestRunner", cloudinary.config.apiSecret); String expected_signature = cloudinary.apiSignRequest(to_sign, cloudinary.config.apiSecret); Assert.assertEquals(result.get("signature"), expected_signature); }
Example #21
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testUploadUrl() throws Exception { if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject(cloudinary.uploader().upload("http://cloudinary.com/images/old_logo.png", ObjectUtils.emptyMap())); Assert.assertEquals(result.getLong("width"), 241L); Assert.assertEquals(result.getLong("height"), 51L); Map<String, Object> to_sign = new HashMap<String, Object>(); to_sign.put("public_id", (String) result.get("public_id")); to_sign.put("version", ObjectUtils.asString(result.get("version"))); String expected_signature = cloudinary.apiSignRequest(to_sign, cloudinary.config.apiSecret); Assert.assertEquals(result.get("signature"), expected_signature); }
Example #22
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testExplicit() throws Exception { if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject(cloudinary.uploader().explicit("sample", ObjectUtils.asMap("eager", Collections.singletonList(new Transformation().crop("scale").width(2.0)), "type", "upload"))); String url = cloudinary.url().transformation(new Transformation().crop("scale").width(2.0)).format("jpg") .version(result.get("version")).generate("sample"); Assert.assertEquals(url, result.getJSONArray("eager").getJSONObject(0).get("url")); }
Example #23
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testEager() throws Exception { if (cloudinary.config.apiSecret == null) return; cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("eager", Collections.singletonList(new Transformation().crop("scale").width(2.0)))); }
Example #24
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testUploadAsync() throws Exception { if (cloudinary.config.apiSecret == null) return; JSONObject result = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("transformation", new Transformation().crop("scale").width(2.0), "async", true))); Assert.assertEquals(result.getString("status"), "pending"); }
Example #25
Source File: UploaderTest.java From cloudinary_android with MIT License | 5 votes |
@Test public void testHeaders() throws Exception { if (cloudinary.config.apiSecret == null) return; cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("headers", new String[]{"Link: 1"})); cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("headers", ObjectUtils.asMap("Link", "1"))); }
Example #26
Source File: UploaderTest.java From cloudinary_android with MIT License | 4 votes |
@Test public void testFilenameOption() throws Exception { JSONObject result = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.asMap("filename", "emanelif"))); Assert.assertEquals("emanelif", result.getString("original_filename")); }
Example #27
Source File: UploadRequest.java From cloudinary_android with MIT License | 4 votes |
@SuppressWarnings("unchecked") static Map<String, Object> decodeOptions(String encoded) throws IOException, ClassNotFoundException { return (Map<String, Object>) ObjectUtils.deserialize(encoded); }
Example #28
Source File: UploadRequest.java From cloudinary_android with MIT License | 4 votes |
static String encodeOptions(Map<String, Object> options) throws IOException { return ObjectUtils.serialize(options); }
Example #29
Source File: DefaultRequestProcessor.java From cloudinary_android with MIT License | 4 votes |
private Map doProcess(final String requestId, Context appContext, Map<String, Object> options, RequestParams params, Payload payload) throws PayloadNotFoundException, IOException, ErrorRetrievingSignatureException { Logger.d(TAG, String.format("Starting upload for request %s", requestId)); Object preparedPayload = payload.prepare(appContext); final long actualTotalBytes = payload.getLength(appContext); final long offset = params.getLong("offset", 0); final int bufferSize; final String uploadUniqueId; int defaultBufferSize = options.containsKey("chunk_size") ? (int) options.get("chunk_size") : Uploader.BUFFER_SIZE; if (offset > 0) { // this is a RESUME operation, buffer size needs to be consistent with previous parts: bufferSize = params.getInt("original_buffer_size", defaultBufferSize); uploadUniqueId = params.getString("original_upload_id", null); } else { bufferSize = ObjectUtils.asInteger(options.get("chunk_size"), defaultBufferSize); uploadUniqueId = new Cloudinary().randomPublicId(); } // if there are no credentials and the request is NOT unsigned - activate the signature provider (if present). if (!MediaManager.get().hasCredentials() && !TRUE.equals(options.get("unsigned"))) { SignatureProvider signatureProvider = MediaManager.get().getSignatureProvider(); if (signatureProvider != null) { try { Signature signature = signatureProvider.provideSignature(options); options.put("signature", signature.getSignature()); options.put("timestamp", signature.getTimestamp()); options.put("api_key", signature.getApiKey()); } catch (Exception e) { throw new ErrorRetrievingSignatureException("Could not retrieve signature from the given provider: " + signatureProvider.getName(), e); } } } final ProcessorCallback processorCallback = new ProcessorCallback(actualTotalBytes, offset, callbackDispatcher, requestId); try { return MediaManager.get().getCloudinary().uploader().uploadLarge(preparedPayload, options, bufferSize, offset, uploadUniqueId, processorCallback); } finally { // save data into persisted request params to enable resuming later on params.putInt("original_buffer_size", bufferSize); params.putLong("offset", processorCallback.bytesUploaded - processorCallback.bytesUploaded % bufferSize); params.putString("original_upload_id", uploadUniqueId); } }
Example #30
Source File: UploaderTest.java From cloudinary_android with MIT License | 4 votes |
public void testConnectTimeout() throws IOException { cloudinary.uploader().unsignedUpload(getAssetStream(TEST_IMAGE), TEST_PRESET, ObjectUtils.asMap("connect_timeout", 1)); }