fix(ios): iosGetImageDataById for videos (#500)

* Fix get video data with iosGetImageDataById

* Update README.md with uploading example
This commit is contained in:
Vasile
2023-06-23 11:09:07 +02:00
committed by GitHub
parent 0b4ceaa0bf
commit ab3be84b9b
2 changed files with 22 additions and 1 deletions
+15
View File
@@ -480,6 +480,21 @@ CameraRoll.iosGetImageDataById(internalID, true);
| internalID | string | Yes | Ios internal ID 'PH://xxxx'. |
| convertHeic | boolean | False | Whether to convert or not to JPEG image. |
Upload photo/video with `iosGetImageDataById` method
```javascript
try {
// uri 'PH://xxxx'
const fileData = await CameraRoll.iosGetImageDataById(uri);
if (!fileData?.node?.image?.filepath) return undefined;
const uploadPath = imageData.node.image.filepath; // output should be file://...
// fetch or ReactNativeBlobUtil.fetch to upload
}
catch (error) {}
```
### `useCameraRoll()`
+7 -1
View File
@@ -629,7 +629,13 @@ RCT_EXPORT_METHOD(getPhotoByInternalID:(NSString *)internalId
editOptions.networkAccessAllowed = YES;
[asset requestContentEditingInputWithOptions:editOptions completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
imageURL = contentEditingInput.fullSizeImageURL;
if (contentEditingInput.mediaType == PHAssetMediaTypeImage) {
imageURL = contentEditingInput.fullSizeImageURL;
} else {
AVURLAsset *avURLAsset = (AVURLAsset*)contentEditingInput.audiovisualAsset;
imageURL = [avURLAsset URL];
}
if (imageURL.absoluteString.length != 0) {
filePath = [imageURL.absoluteString stringByReplacingOccurrencesOfString:@"pathfile:" withString:@"file:"];