NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString * documentPath = [paths objectAtIndex:0];
NSString *temp = [NSString stringWithFormat:@"%@/temp.txt", documentPath];
NSLog(temp);
// create our stream
NSOutputStream *outputStream =
[[NSOutputStream alloc] initToFileAtPath:temp append:YES];
[outputStream open];
// create our request
S3GetObjectRequest *getObjectRequest =
[[S3GetObjectRequest alloc] initWithKey:self.objectName
withBucket:self.bucket];
getObjectRequest.outputStream = outputStream;
// always make sure to close your streams when done
[outputStream close];
答案 0 :(得分:2)
您需要使用NSSearchPathForDirectoriesInDomains
获取应用程序的文档目录,并使用它来构建文件路径和名称。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [paths objectAtIndex:0];