No Description

RNFetchBlobConfig.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.RNFetchBlob;
  2. import com.facebook.react.bridge.ReadableArray;
  3. import com.facebook.react.bridge.ReadableMap;
  4. class RNFetchBlobConfig {
  5. public Boolean fileCache;
  6. public String path;
  7. public String appendExt;
  8. public ReadableMap addAndroidDownloads;
  9. public Boolean trusty;
  10. public String key;
  11. public String mime;
  12. public Boolean auto;
  13. public Boolean overwrite = true;
  14. public long timeout = 60000;
  15. public Boolean increment = false;
  16. public Boolean followRedirect = true;
  17. public ReadableArray binaryContentTypes = null;
  18. RNFetchBlobConfig(ReadableMap options) {
  19. if(options == null)
  20. return;
  21. this.fileCache = options.hasKey("fileCache") ? options.getBoolean("fileCache") : false;
  22. this.path = options.hasKey("path") ? options.getString("path") : null;
  23. this.appendExt = options.hasKey("appendExt") ? options.getString("appendExt") : "";
  24. this.trusty = options.hasKey("trusty") ? options.getBoolean("trusty") : false;
  25. if(options.hasKey("addAndroidDownloads")) {
  26. this.addAndroidDownloads = options.getMap("addAndroidDownloads");
  27. }
  28. if(options.hasKey("binaryContentTypes"))
  29. this.binaryContentTypes = options.getArray("binaryContentTypes");
  30. if(this.path != null && path.toLowerCase().contains("?append=true")) {
  31. this.overwrite = false;
  32. }
  33. if(options.hasKey("overwrite"))
  34. this.overwrite = options.getBoolean("overwrite");
  35. if(options.hasKey("followRedirect")) {
  36. this.followRedirect = options.getBoolean("followRedirect");
  37. }
  38. this.key = options.hasKey("key") ? options.getString("key") : null;
  39. this.mime = options.hasKey("contentType") ? options.getString("contentType") : null;
  40. this.increment = options.hasKey("increment") ? options.getBoolean("increment") : false;
  41. this.auto = options.hasKey("auto") ? options.getBoolean("auto") : false;
  42. if(options.hasKey("timeout")) {
  43. this.timeout = options.getInt("timeout");
  44. }
  45. }
  46. }