html5 - Phonegap File transfer errors -
i'm trying phonegap app create directory on mobile device, keep running same errors, mixture of:
encoding_err - 5 - url malformed. make sure url complete , valid.
path_exists_err - 12 - file or directory same path exists.
invalid_modification_err - 9 - modification requested not allowed. example, app might trying move directory own child or moving file parent directory without changing name.
$( document ).on( 'click', '#a2', function () { downloadphoto(); } ); function downloadphoto() { alert( "downloading" ); window.requestfilesystem( localfilesystem.persistent, 0, function systemsuccess( direntry ) { alert( "download begin" ); direntry.root.getdirectory( 'thisfilenamewillneverexist', { create: true }, function ( filesystem ) { alert( filesystem ); }, errorhandler ); }, errorhandler ); } function errorhandler( e ) { var msg = ''; switch ( e.code ) { case fileerror.encoding_err: msg = 'encoding_err'; break; case fileerror.invalid_modification_err: msg = 'invalid_modification_err'; break; case fileerror.invalid_state_err: msg = 'invalid_state_err'; break; case fileerror.no_modification_allowed_err: msg = 'no_modification_allowed_err'; break; case fileerror.not_found_err: msg = 'not_found_err'; break; case fileerror.not_readable_err: msg = 'not_readable_err'; break; case fileerror.path_exists_err: msg = 'path_exists_err'; break; case fileerror.quota_exceeded_err: msg = 'quota_exceeded_err'; break; case fileerror.security_err: msg = 'security_err'; break; case fileerror.type_mismatch_err: msg = 'type_mismatch_err'; break; default: msg = 'unknown error'; break; }; alert( 'error: ' + msg ); }
why or how file name exist if first time i'm creating it?
managed fix error, turns out dont need include "root" when creating file in newly created directory.
code else stuck on problem or similar:
var folderdir; var filedir; var foldername = "osmaps"; $( document ).on( 'click', '#a2', function () { window.requestfilesystem( localfilesystem.persistent, 0, downloadphoto, errorhandler); } ); function downloadphoto(filesystem) { filesystem.root.getdirectory( foldername, { create: true, exclusive: false }, function ( direntry ) { folderdir = direntry; -> folderdir.getfile( 'test.jpg', { create: true, exclusive: false }, <- function ( fileentry ) { filedir = fileentry; }, errorhandler ); }, errorhandler );
Comments
Post a Comment