Skip to content

Windows UWP: Different URL type for DestinationType.FILE_URI when using PictureSourceType.SAVEDPHOTOALBUM #671

@kryops

Description

@kryops

Bug Report

Problem

When specifying DestinationType.FILE_URI, the URL types on Windows UWP are different for images captured by the camera than they are for images selected from the hard drive.

What is expected to happen?

The URLs returned by this plugin should have the same type independent of the picture source.

What does actually happen?

  • Camera.PictureSourceType.CAMERA => ms-appdata:///local/CCapture.jpg
  • Camera.PictureSourceType.SAVEDPHOTOALBUM => blob:ms-appx://<APPID>/<GUID>

Information

Before 5.0.0, we used Camera.DestinationType.NATIVE_URI on Windows UWP, which would return URLs similar to what Camera.PictureSourceType.CAMERA does. However, this destination type was removed in #637

With 5.0.0, the best workaround I could come up with was patching CameraProxy.js:

const newContent = fileContent.replace(
  /successCallback\(URL\.createObjectURL\(storageFile\)\);/g,
  "successCallback('ms-appdata:///local/' + storageFile.name);"
);

Is there a reason why the Blob URLs were chosen as FILE_URI for Windows UWP? Could they be replaced by the URLs formerly returned for NATIVE_URI?

Note: #668 seems to already change this behavior

Command or Code

Complete options:

{
    quality: 50,
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
    encodingType: Camera.EncodingType.JPEG,
    mediaType: Camera.MediaType.PICTURE,
    allowEdit: false,
    correctOrientation: true,
    targetWidth: undefined,
    targetHeight: undefined,
  }

Environment, Platform, Device

Windows UWP, Windows 10/2004

Version information

cordova 10.0.0
cordova-windows 7.0.1
cordova-plugin-camera 5.0.0

Checklist

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions