mirror of
https://github.com/status-im/react-native-camera-roll.git
synced 2026-08-27 11:21:08 +00:00
fix(ios): iosGetImageDataById for videos (#500)
* Fix get video data with iosGetImageDataById * Update README.md with uploading example
This commit is contained in:
@@ -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()`
|
||||
|
||||
@@ -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:"];
|
||||
|
||||
Reference in New Issue
Block a user