0

ボックス開発者サイトから以下を入手しました。

curl https://upload.box.com/api/2.0/files/content \
-H "Authorization: Bearer ACCESS_TOKEN" \
-F filename=@FILE_NAME \
-F parent_id=PARENT_FOLDER_ID
  • Fは何を示していますか?リクエストURLの作り方は?
4

3 に答える 3

0

ボックスへのファイルのアップロードは非常に簡単です。以下のコードを見つけてください。

- (void)performSampleUpload:(id)sender
{
    BoxFileBlock fileBlock = ^(BoxFile *file)
    {
        [self fetchFolderItemsWithFolderID:self.folderID name:self.navigationController.title];

        dispatch_sync(dispatch_get_main_queue(), ^{
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"File Upload Successful" message:[NSString stringWithFormat:@"File has id: %@", file.modelID] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
        });
    };

    BoxAPIJSONFailureBlock failureBlock = ^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSDictionary *JSONDictionary)
    {
        BOXLog(@"status code: %i", response.statusCode);
        BOXLog(@"upload response JSON: %@", JSONDictionary);
    };

    BoxFilesRequestBuilder *builder = [[BoxFilesRequestBuilder alloc] init];
    builder.name = @"Logo_Box_Blue_Whitebg_480x480.jpg";
    builder.parentID = self.folderID;

    NSString *path = [[NSBundle mainBundle] pathForResource:@"Logo_Box_Blue_Whitebg_480x480.jpg" ofType:nil];
    NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:path];
    NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];
    long long contentLength = [[fileAttributes objectForKey:NSFileSize] longLongValue];

    [[BoxSDK sharedSDK].filesManager uploadFileWithInputStream:inputStream contentLength:contentLength MIMEType:nil requestBuilder:builder success:fileBlock failure:failureBlock progress:nil];
}

コーディングをお楽しみください.乾杯.

于 2014-08-20T07:23:38.310 に答える
0

ここで私は解決策を得ました。

   NSString * accessToken =  [[arrUseraccounts objectAtIndex:[DropboxDownloadFileViewControlller getSharedInstance].index] objectForKey:@"acces_token"];
    NSString * filename = [NSString stringWithFormat:@"@%@",[[filePathsArray objectAtIndex:k]objectForKey:@"PdfName"]];
    NSString * boxParentId = [DetailViewController  getSharedInstance].folderPath;

    NSString *str =  [NSString stringWithFormat:@"https://upload.box.com/api/2.0/files/content?access_token=%@&filename=%@&parent_id=%@",accessToken,filename,boxParentId];

    ASIFormDataRequest *postParams = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:str]];
    postParams.delegate = self ;
    postParams.userInfo = [NSDictionary dictionaryWithObject:@"upload" forKey:@"id"];
// set the path of the file where it is saved (local Path)
    [postParams setFile:[[filePathsArray objectAtIndex:k]objectForKey:@"PdfPath"] forKey:@"filename"];

    [postParams startAsynchronous];
于 2014-08-19T10:06:18.553 に答える