Closed reallylongaddress closed 10 years ago
After a bit more coding...i've moved the md5 function so it's accessed via all filepath generation:
if ([URLString hasPrefix:@"data:"]) return nil;
NSString *filepath = [URLString stringByRegex:@"._://" substitution:@""];
NSString filepath1 = [filepath stringByRegex:@":[0-9]?/" substitution:@""];
NSString filepath2 = [filepath1 stringByRegex:@"#." substitution:@""];
NSString filepath3 = [filepath2 stringByRegex:@"\?." substitution:@""];
NSString filepath4 = [filepath3 stringByRegex:@"//" substitution:@"/"];
NSLog(@"fielnameForURLString: %@", [StringUtils returnMD5Hash:filepath4]);
return [StringUtils returnMD5Hash:filepath4];
// return filepath4;
}
//DBD modified this to shorten the filename, else we get a 'file name too long' error
(NSString )filePathForURL: (NSURL ) url {
NSLog(@"filePathForURL: %@", [dataPath stringByAppendingPathComponent:[self filenameForURL: url]]); return [dataPath stringByAppendingPathComponent:[self filenameForURL: url]]; }
Filenames are hashes now, so this won't happen anymore.
Hi there...
Been playing with your AFCache and got the above error (My urls are pretty darn long). So here's my hack/fix...do as you wish with it:
2011-10-09 09:57:45.091 MobileIgniter[7629:207] Error: could not create file "/Users/dominic/Library/Application Support/iPhone Simulator/4.0.2/Applications/99347D6D-885F-4E87-9D6B-7F553CC96062/Library/Caches/com.mobileigniter.proofofconcept.tropicana/localhost:8888/modules/index.php/listDetail/?signed_request=8mIgkXSbpKrxnKdIM1moOzTN66oFqSukvgwkS_HltWs.eyJ0aXRsZSI6IlRyb3BpY2FuYSBEZWFscyIsIm1vZHVsZV9rZXkiOiJsaXN0X2RldGFpbF9tb2R1bGVfa2V5IiwibW9kdWxlX2luc3RhbmNlX2tleSI6IndrbXozMjh2MGtubGFydmM4ZTM5ZzVkbGZtcjJqYzI2In0&system_name=iPhone%20OS&system_version=4.0.2"
2011-10-09 09:57:45.098 MobileIgniter[7629:207] Error was code: 63 - message: File name too long
----SO I shortened the url part of the filename via MD5-----
(NSString )filePathForURL: (NSURL ) url {
NSLog(@"dataPath: %@", dataPath); NSLog(@"filenameForUrl: %@", [self filenameForURL: url]);
//dbd let's md5 the url else we get an error (Error was code: 63 - message: File name too long) NSString *hashedFilename = [StringUtils returnMD5Hash:[self filenameForURL: url]];
NSLog(@"hashedFilename: %@", hashedFilename);
NSLog(@"before/after %i/%i", [[self filenameForURL: url] length], [hashedFilename length]);
return [dataPath stringByAppendingPathComponent:hashedFilename]; }
----WHERE MD5 generated via--- //generate md5 hash from string
}
Best, Dominic