拍照并将其保存到图库并重命名

时间:2019-09-11 14:15:37

标签: android angularjs cordova ionic-framework

我是Cordova插件的初学者 我使用此选项将图像保存到图库

    var options = {
        quality: (device.platform == "iOS" ? 60 : 80),
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.CAMERA,
        encodingType: Camera.EncodingType.JPEG,      
        targetWidth: 800,
        targetHeight: 800,
        popoverOptions: CameraPopoverOptions,
        correctOrientation: true,
        saveToPhotoAlbum: true
    }

在$ cordovaCamera.getPicture插件中 此代码将我的图片保存在图库中。但是我想重命名这张照片。

我正在关注这些链接,但此链接未将图像保存在图库中。

How to move captured image taken by Android phone to another folder using Phonegap

https://devdactic.com/how-to-capture-and-store-images-with-ionic/

    window.resolveLocalFileSystemURI(imgData, resolveOnSuccess, resOnError);

        function resolveOnSuccess(entry) {
            var d = new Date();
            var n = d.getTime();
            //new file name
            var newFileName = "test" + ".jpg";
            var myFolderApp = "EasyPacking";

            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSys) {
                //The folder is created if doesn't exist
                fileSys.root.getDirectory(myFolderApp, { create: true, exclusive: false },
                    function (directory) {
                        entry.moveTo(directory, newFileName, successMove, resOnError);
                    },
                    resOnError);
            },
                resOnError);
        }

        //Callback function when the file has been moved successfully - inserting the complete path
        function successMove(entry) {
            console.log(entry);
            //I do my insert with "entry.fullPath" as for the path
        }

        function resOnError(error) {
            alert(error.code);
        }

我要去哪里了,还是可以在android和ios中重命名图像并将其保存到图库。

0 个答案:

没有答案