Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
  2. <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
  3.  
  4. android:largeHeap="true"
  5.  
  6. downloadFile: {
  7.  
  8. run: function(uri, fileName, folderName) {
  9.  
  10. var that = this;
  11.  
  12. filePath = "";
  13.  
  14. that.getFilesystem(
  15. function(fileSystem) {
  16. console.log("gotFS");
  17.  
  18. if (APP.isAndroid()) {
  19. that.getFolder(
  20. fileSystem,
  21. folderName,
  22. function(folder) {
  23. filePath = folder.toURL() + "/" + fileName;
  24. console.log("FILE PATH :::: " + filePath);
  25. that.transferFile(uri, filePath);
  26. }, function() {
  27. console.log("failed to get folder");
  28. }
  29. );
  30. }
  31. else {
  32. filePath = fileSystem.root.fullPath + "/" + fileName;
  33. that.transferFile(uri, filePath);
  34. }
  35. },
  36. function() {
  37. console.log("failed to get filesystem");
  38. }
  39. );
  40. },
  41.  
  42. getFilesystem:function (success, fail) {
  43. window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
  44. window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, success, fail);
  45. },
  46.  
  47. getFolder: function (fileSystem, folderName, success, fail) {
  48. fileSystem.root.getDirectory(folderName, {create: true, exclusive: false}, success, fail)
  49. },
  50.  
  51.  
  52. transferFile: function (uri, filePath) {
  53. var transfer = new FileTransfer();
  54. console.log("Trying to DL : : " + encodeURI(uri) + " to " + filePath);
  55. /** **/
  56. transfer.download(
  57. encodeURI(uri),
  58. filePath,
  59. function (entry) {
  60. console.log("TRYING TO OPEN FILE ::: " + entry.toURL());
  61. },
  62. function (error) {
  63. console.log("download error source " + error.source);
  64. console.log("download error target " + error.target);
  65. console.log("upload error code" + error.code);
  66. }
  67. );
  68. }
  69. },
  70.  
  71. this.downloadFile.run(url, "file_name.pdf", "pdfs");
  72.  
  73. I/chromium(26125): [INFO:CONSOLE(388)] "TRYING TO OPEN FILE ::: cdvfile://localhost/persistent/fileName", source: file:///android_asset/www/app/env.js (388)
  74. F/libc (26125): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 26203 (GAThread)
  75. I/DEBUG ( 269): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  76. I/DEBUG ( 269): Build fingerprint: 'motorola/falcon_asia_ds/falcon_umtsds:4.4.2/KXB20.25-1.31/14:user/release-keys'
  77. I/DEBUG ( 269): Revision: 'p3c0'
  78. I/DEBUG ( 269): pid: 26125, tid: 26203, name: GAThread >>> nz.co.forsythbarr.mobileapp <<<
  79. I/DEBUG ( 269): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
  80. D/WifiStateMachine( 1010): handleMessage: E msg.what=151572
  81. D/WifiStateMachine( 1010): processMsg: ConnectedState
  82. D/WifiStateMachine( 1010): processMsg: L2ConnectedState
  83. I/DEBUG ( 269): r0 00000000 r1 00000000 r2 625ca245 r3 00000028
  84. I/DEBUG ( 269): r4 00000008 r5 625ca246 r6 00000000 r7 ffffffff
  85. I/DEBUG ( 269): r8 00000001 r9 40b59130 sl 00000028 fp 625ca245
  86. I/DEBUG ( 269): ip 6402fb34 sp 64a39990 lr 64024105 pc 40b440f6 cpsr 600f0030
  87. I/DEBUG ( 269): d0 0000000000000000 d1 0000000000000000
  88. I/DEBUG ( 269): d2 0000000000000000 d3 0000000000000000
  89. I/DEBUG ( 269): d4 3268053561342f79 d5 796470730830312d
  90. I/DEBUG ( 269): d6 64707306312e332f d7 7074746808332f79
  91. I/DEBUG ( 269): d8 0000000000000000 d9 0000000000000000
  92. I/DEBUG ( 269): d10 0000000000000000 d11 0000000000000000
  93. I/DEBUG ( 269): d12 0000000000000000 d13 0000000000000000
  94. I/DEBUG ( 269): d14 0000000000000000 d15 0000000000000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement