Skip to content

Commit

Permalink
Fix iOS image and video filename from gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Nov 18, 2024
1 parent d86a4f5 commit 214030c
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/core/platforms/ios/iosresourcesource.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,9 @@ - (void)imagePickerController:(UIImagePickerController *)picker
kCFCompareEqualTo) {
NSURL *videoUrl =
(NSURL *)[info objectForKey:UIImagePickerControllerMediaURL];
const QString originalFilename =
QString::fromNSString([videoURL lastPathComponent]);

/*
NSString *moviePath = [videoUrl path];*/
// For now, hardcode a dummy filename until the above code can be reviewed
// by person with iOS background and made to work
const QString originalFilename = QStringLiteral("%1.%2").arg(
QString::number(QDateTime::currentSecsSinceEpoch()), "MP4");
QString finalResourceFilePath = mIosCamera->resourceFilePath();
if (!originalFilename.isEmpty()) {
QFileInfo fi(originalFilename);
Expand All @@ -74,15 +70,11 @@ - (void)imagePickerController:(UIImagePickerController *)picker

emit mIosCamera->resourceReceived(finalResourceFilePath);
} else {
/*
NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];
PHAsset *phAsset = [[PHAsset fetchAssetsWithALAssetURLs:@[ imageURL ]
options:nil] lastObject];
const QString originalFilename([phAsset valueForKey:@"filename"]);*/
// For now, hardcode a dummy filename until the above code can be reviewed
// by person with iOS background and made to work
const QString originalFilename = QStringLiteral("%1.%2").arg(
QString::number(QDateTime::currentSecsSinceEpoch()), "JPG");
NSURL *imageURL =
(NSURL *)[info objectForKey:UIImagePickerControllerImageURL];
const QString originalFilename =
QString::fromNSString([imageURL lastPathComponent]);

QString finalResourceFilePath = mIosCamera->resourceFilePath();
if (!originalFilename.isEmpty()) {
QFileInfo fi(originalFilename);
Expand Down

0 comments on commit 214030c

Please sign in to comment.