No Description

RNFetchBlobConfig.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.RNFetchBlob;
  2. import com.facebook.react.bridge.ReadableArray;
  3. import com.facebook.react.bridge.ReadableMap;
  4. import java.util.HashMap;
  5. public class RNFetchBlobConfig {
  6. public Boolean fileCache;
  7. public String path;
  8. public String appendExt;
  9. public ReadableMap addAndroidDownloads;
  10. public Boolean trusty;
  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. if(options.hasKey("addAndroidDownloads")) {
  27. this.addAndroidDownloads = options.getMap("addAndroidDownloads");
  28. }
  29. if(options.hasKey("binaryContentTypes"))
  30. this.binaryContentTypes = options.getArray("binaryContentTypes");
  31. if(this.path != null && path.toLowerCase().contains("?append=true")) {
  32. this.overwrite = false;
  33. }
  34. if(options.hasKey("overwrite"))
  35. this.overwrite = options.getBoolean("overwrite");
  36. if(options.hasKey("followRedirect")) {
  37. this.followRedirect = options.getBoolean("followRedirect");
  38. }
  39. this.key = options.hasKey("key") ? options.getString("key") : null;
  40. this.mime = options.hasKey("contentType") ? options.getString("contentType") : null;
  41. this.increment = options.hasKey("increment") ? options.getBoolean("increment") : false;
  42. this.auto = options.hasKey("auto") ? options.getBoolean("auto") : false;
  43. if(options.hasKey("timeout")) {
  44. this.timeout = options.getInt("timeout");
  45. }
  46. }
  47. }