1

我将我的全部数据存储在zip file. 现在我想zip file通过my app.
我有一些示例(通过谷歌搜索)使用这些示例,我只能存储图像,但我无法zip file通过我的应用程序将其存储在 Evernote 中。


请帮助有什么方法可以将zip文件存储在evernote中


我正在使用以下代码发布图像及其描述

-(IBAction)authenticate:(id)sender  
{    
   EvernoteSession *session = [EvernoteSession sharedSession];  
   [session authenticateWithViewController:self completionHandler:^(NSError *error) {
      if (error || !session.isAuthenticated)  
     {

            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                  message:@"Could notauthenticate" delegate:nil
                                  cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        } else {
            NSLog(@"authenticated! noteStoreUrl:%@ webApiUrlPrefix:%@", session.noteStoreUrl, session.webApiUrlPrefix);
        }
    }];
}`


-(IBAction)Postdata:(id)sender {

    NSString* filePath = [[NSBundle mainBundle] pathForResource:@"setting_tablecell" ofType:@"png"];
    NSData *myFileData = [NSData dataWithContentsOfFile:filePath];
    NSData *dataHash = [myFileData md5];
    EDAMData *edamData = [[EDAMData alloc] initWithBodyHash:dataHash size:myFileData.length body:myFileData];
    EDAMResource* resource = [[EDAMResource alloc] initWithGuid:nil noteGuid:nil data:edamData mime:@"image/png" width:0 height:0 duration:0 active:0 recognition:0 attributes:nil updateSequenceNum:0 alternateData:nil];
    NSString *noteContent = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                             "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
                             "<en-note>"
                             "<span style=\"font-weight:bold;\">Hello photo note.</span>"
                             "<br />"
                             "<span>Evernote logo :</span>"
                             "<br />"
                             "%@"
                             "</en-note>",[ENMLUtility mediaTagWithDataHash:dataHash mime:@"image/png"]];

    NSMutableArray* resources = [NSMutableArray arrayWithArray:@[resource]];
    EDAMNote *newNote = [[EDAMNote alloc] initWithGuid:nil title:@"Test photo note Nyt" content:noteContent contentHash:nil contentLength:noteContent.length created:0 updated:0 deleted:0 active:YES updateSequenceNum:0 notebookGuid:nil tagGuids:nil resources:resources attributes:nil tagNames:nil];
    [[EvernoteNoteStore noteStore] createNote:newNote success:^(EDAMNote *note) {
        NSLog(@"Note created successfully.");
    } failure:^(NSError *error) {
        NSLog(@"Error creating note : %@",error);
    }];
}
4

1 回答 1

1

创建 EDAMResource 对象时,将 mime 类型更改为“application/zip”。

EDAMResource* resource = [[EDAMResource alloc] initWithGuid:nil noteGuid:nil data:edamData mime:@"application/zip" width:0 height:0 duration:0 active:0 recognition:0 attributes:nil updateSequenceNum:0 alternateData:nil];
于 2013-02-15T06:12:21.560 回答