List of usage examples for com.facebook.react.bridge Promise reject
void reject(String code, String message, @NonNull WritableMap userInfo);
From source file:com.amazonaws.reactnative.s3.AWSRNS3TransferUtility.java
License:Open Source License
@ReactMethod public void download(final ReadableMap options, final Promise promise) { if (!options.hasKey(REQUESTID)) { throw new IllegalArgumentException("requestid is not supplied"); }// w w w. j a v a2 s. c o m final String requestID = options.getString(REQUESTID); final Map<String, Object> map = requestMap.get(requestID); if (map == null) { throw new IllegalArgumentException("requestid is invalid"); } final TransferObserver observer; try { observer = transferUtility.download((String) map.get(BUCKET), (String) map.get(KEY), new File((String) map.get(PATH))); } catch (final AmazonServiceException e) { promise.reject(e.getErrorCode(), e.getErrorMessage(), e); return; } catch (final AmazonClientException e) { promise.reject("", e.getMessage(), e); return; } transferIDMap.put(observer.getId(), requestID); map.put(TRANSFERID, observer.getId()); if ((Boolean) map.get(SUBSCRIBE)) { this.subscribe(observer); } promise.resolve("success"); }
From source file:com.amazonaws.reactnative.s3.AWSRNS3TransferUtility.java
License:Open Source License
@ReactMethod public void upload(final ReadableMap options, final Promise promise) { if (!options.hasKey(REQUESTID)) { throw new IllegalArgumentException("requestid is not supplied"); }// www. j av a2 s. c o m final String requestID = options.getString(REQUESTID); final Map<String, Object> map = requestMap.get(requestID); if (map == null) { throw new IllegalArgumentException("requestid is invalid"); } final TransferObserver observer; try { observer = transferUtility.upload((String) map.get(BUCKET), (String) map.get(KEY), new File((String) map.get(PATH))); } catch (final AmazonServiceException e) { promise.reject(e.getErrorCode(), e.getErrorMessage(), e); return; } catch (final AmazonClientException e) { promise.reject("", e.getMessage(), e); return; } transferIDMap.put(observer.getId(), requestID); map.put(TRANSFERID, observer.getId()); if ((Boolean) map.get(SUBSCRIBE)) { this.subscribe(observer); } promise.resolve("success"); }