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 19, 2024
1 parent d86a4f5 commit 6e9213c
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

1 comment on commit 6e9213c

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.