首页 文章

如何在文件传输中使用Cordova Camera插件?

提问于
浏览
0

I am trying to upload a photo taken from the camera, but running into issues with tying the resulting photo with file transfer.

我安装了以下插件:cordova-plugin-camera,cordova-plugin-file,cordova-plugin-file-transfer

我可以拍摄照片并在离子页面中显示 . 我不明白的是如何将该照片与文件传输过程联系起来 . 拍摄和上传的实时照片的真实端到端示例 .

到目前为止,我遇到了许多拍摄照片的示例 - 或 - 上传以前存在的文件 . 但不是一气呵成 .

在相关的说明中,我使用浏览器相机功能,并可以成功将文件对象上传到我的Web服务(用C#编写) . 它适用于iOS,但最近Android设备不再提供由于某种原因拍摄的实时照片(很想知道原因) .

Are there any end-to-end examples of taking a photo, uploading it -- and -- into a C# written web-service?

1 回答

  • 3

    你有没有试过这样做:

    var options = {
        quality: 75,
        destinationType: Camera.DestinationType.FILE_URL,
        sourceType: Camera.PictureSourceType.CAMERA,
        allowEdit: false,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 720,
        targetHeight: 1280,
        popoverOptions: CameraPopoverOptions,
        saveToPhotoAlbum: false,
        correctOrientation: true
    };
    
    return $cordovaCamera.getPicture(options).then(upload);
    
    function upload(filePath) {
        return $cordovaFileTransfer.upload('http://example.com', filePath, {
            fileKey: 'file',
            fileName: 'example.jpeg',
            mimeType: 'image/jpeg'
        });
    }
    

相关问题