No Description

RNFetchBlobConfig.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 Boolean wifiOnly = false;
  11. public String key;
  12. public String mime;
  13. public Boolean auto;
  14. public Boolean overwrite = true;
  15. public long timeout = 60000;
  16. public Boolean increment = false;
  17. public Boolean followRedirect = true;
  18. public ReadableArray binaryContentTypes = null;
  19. RNFetchBlobConfig(ReadableMap options) {
  20. if(options == null)
  21. return;
  22. this.fileCache = options.hasKey("fileCache") ? options.getBoolean("fileCache") : false;
  23. this.path = options.hasKey("path") ? options.getString("path") : null;
  24. this.appendExt = options.hasKey("appendExt") ? options.getString("appendExt") : "";
  25. this.trusty = options.hasKey("trusty") ? options.getBoolean("trusty") : false;
  26. this.wifiOnly = options.hasKey("wifiOnly") ? options.getBoolean("wifiOnly") : false;
  27. if(options.hasKey("addAndroidDownloads")) {
  28. this.addAndroidDownloads = options.getMap("addAndroidDownloads");
  29. }
  30. if(options.hasKey("binaryContentTypes"))
  31. this.binaryContentTypes = options.getArray("binaryContentTypes");
  32. if(this.path != null && path.toLowerCase().contains("?append=true")) {
  33. this.overwrite = false;
  34. }
  35. if(options.hasKey("overwrite"))
  36. this.overwrite = options.getBoolean("overwrite");
  37. if(options.hasKey("followRedirect")) {
  38. this.followRedirect = options.getBoolean("followRedirect");
  39. }
  40. this.key = options.hasKey("key") ? options.getString("key") : null;
  41. this.mime = options.hasKey("contentType") ? options.getString("contentType") : null;
  42. this.increment = options.hasKey("increment") ? options.getBoolean("increment") : false;
  43. this.auto = options.hasKey("auto") ? options.getBoolean("auto") : false;
  44. if(options.hasKey("timeout")) {
  45. this.timeout = options.getInt("timeout");
  46. }
  47. }
  48. }