I have this simple method that check if i pass a parameter like "/testPhoto", and if, it is passed, i want try to answer with a simple image that has the path that you can see in the variable "testPath" (static path for try). At the moment, when i do the request, i receive the 200 ok status from the server, but no data is passed (0 Bytes). I need to understand what i'm doing wrong. Maybe the testPath doesn't contains a correct path? The path that i'm using is found using the ALAssetslibrary.
- (NSObject<HTTPResponse> *)httpResponseForMethod:(NSString *)method URI:(NSString *)path{
HTTPLogTrace();
if ([path isEqualToString:@"/testPhoto"]){
NSString *testPath = [[NSString alloc] init];
testPath = @"assets-library://asset/asset.JPG?id=DB96E240-8760-4FD6-B8B4-FEF3F61793B3&ext=JPG";
NSURL *deviceImageUrl = [[NSURL alloc] initWithString:testPath];
NSData *imageData = [NSData dataWithContentsOfURL:deviceImageUrl];
UIImage *deviceImage = [UIImage imageWithData:imageData];
HTTPDataResponse *photoResponse = [[HTTPDataResponse alloc] initWithData:imageData];
return photoResponse;
}
return nil;
}
Thanks
The problem is how you access the assets-library URL. This is not a standard URL and loading the data from an assets-library URL does not work like this. Here is an example how to do it: Getting NSData from an NSURL
The following code is based on the above example. I'm not an expert in
ALAssetLibrary, so try it with care. It needs quite some code to make the asynchronous working of the asset library synchronous again: