Wie man die Datei-Größe der Datei aus dem iPhone-Ordner "Dokumente"
Habe ich, in dem ich speichern Sie die video-Datei in den Ordner Dokumente, es funktioniert gut,aber ich möchte die Datei Größe der Datei habe ich gesucht, aber nicht bekommen Ergebnis mit NSfileManager,hier ist der code den ich verwende für das speichern von video.Ich möchte die Größe der Datei und zeigen Sie es auf UILabel.
Dank
NSURL*videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSLog(@"found a video");
videoData = [[NSData dataWithContentsOfURL:videoURL] retain];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
[dateFormat setDateFormat:@"dd-MM-yyyy_HH:mm:SS"];
NSDate *now = [[[NSDate alloc] init] autorelease];
NSDate* theDate = [dateFormat stringFromDate:now];
NSString*myDate=[dateFormat stringFromDate:theDate];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"Default Album"];
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil];
NSString*test=@"test";
NSString*testUser=[test stringByReplacingOccurrencesOfString:@" " withString:@""];
videopath= [[[NSString alloc] initWithString:[NSString stringWithFormat:@"%@/%@.mp4",documentsDirectory,testUser]] autorelease];
BOOL success = [videoData writeToFile:videopath atomically:NO];
NSLog(@"Successs:::: %@", success ? @"YES" : @"NO");
NSLog(@"video path --> %@",videopath);
NSURL *movieURL = [NSURL fileURLWithPath:videopath];
AVURLAsset *avUrl = [AVURLAsset assetWithURL:movieURL];
CMTime time1 = [avUrl duration];
int seconds = ceil(time1.value/time1.timescale);
// durationTime=[NSString stringWithFormat:@"%d",seconds];
// insertTime=[NSString stringWithFormat:@"%d",seconds];
NSString*messageA=[NSString stringWithFormat:@"You have recorded video of duration of %d seconds ",seconds];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:messageA
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
AVAsset *asset = [AVAsset assetWithURL:movieURL];//url= give your url video here
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset];
CMTime time = CMTimeMake(1, 5);//it will create the thumbnail after the 5 sec of video
CGImageRef imageRef = [imageGenerator copyCGImageAtTime:time actualTime:NULL error:NULL];
UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];
thumbnailImageView.image=thumbnail;
InformationsquelleAutor Aijaz Ali | 2013-10-08
Du musst angemeldet sein, um einen Kommentar abzugeben.
Versuchen dieses dessen Hilfe Sie
diese Datei-Größe in bytes
fileAttributesAtPath:traverseLink: ist veraltet von iOS 6
nutzen Sie auch verwenden attributesOfItemAtPath:Fehler: Methode Ihr auch das gleiche Ergebnis.
Methode ist veraltet. Gehen mit - attributesOfItemAtPath:filePath-Fehler:null
InformationsquelleAutor Sumit Mundra
Hinweis: Oben genannte Methode ist so veraltet, verwenden Sie die folgende Methode
Objective-C:
Swift:
** diese Datei-Größe in bytes
InformationsquelleAutor Hardik Thakkar
Verwenden
NSFileManager attributesOfItemAtPath:error
https://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/attributesOfItemAtPath:error:
Gibt es ein NSDictionary der Datei-Attribute und einen Schlüssel enthält ist NSFileSize, die Größe der Datei.
InformationsquelleAutor ksimons
diesem Weg versuchen.
InformationsquelleAutor user1673099
Vor paar Tagen war ich auch auf der Suche nach etwas sehr ähnlichem. Ich war nötig, um das hochladen der lokalen Datei in die dropbox und hier ist etwas, was für mich gearbeitet: Überprüfen Sie den folgenden link:
https://stackoverflow.com/a/1694928/2098401
InformationsquelleAutor Geekoder