How i can send files from camera with CameraResultType.Uri?
See original GitHub issueimport { Plugins, CameraResultType } from '@capacitor/core';
const { Camera } = Plugins;
async takePicture() {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.Uri
});
var imageUrl = image.webPath;
imageElement.src = imageUrl;
}
How i can send form with a camera image file?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to upload an image coming from the Ionic's Camera to ...
1 Answer 1 · Thank you, I've seen your name quite some times while searching for a solution :). But is there a...
Read more >The Ionic Image Guide with Capacitor (Capture, Store & Upload)
Capturing, storing and uploading image files with Ionic is a crucial ... To test the camera directly in our browser we can also...
Read more >Camera Capacitor Plugin API
If using CameraResultType.Uri, the path will contain a full, platform-specific file URL that can be read later using the Filesystem API. 1.0.0.
Read more >Using the Capacitor Filesystem API to Store Photos
In this tutorial, we will be covering how to use Capacitor to retrieve a photo from the user's camera or photo library, and...
Read more >Taking Photos with the Camera - Ionic Framework
ionic g service services/photo. Copy. Open the new services/photo.service.ts file, and let's add the logic that will power the camera functionality.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Capacitor doesn’t provide a plugin or method for uploading files, you can use XHR or fetch to do so.
As example of how you can do it.
get the blob from the url:
let blob = await fetch(cameraResult.webPath).then(r => r.blob());
or get the blob from the base64:
let blob = b64toBlob(contents.data, "image/jpg", 512);
(google for b64toBlob method).
Once you have the blob, append it to FormData
And upload it with XHR or fetch (example for XHR)
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.