how to upload file to Box subfolder using Java SDK -


how upload files box sub-folder using either subfolder name or id

example have 2 subfolders(subfolder1 , subfolder2) in box, how upload files subfolder2 using java sdk.

can upload using new methods.

successful in uploading files box root folder using code below

    boxfolder bfolder = boxfolder.getrootfolder(api);     fileinputstream stream= null;     filepath = "c:\\uploadfile.txt";      stream = new fileinputstream(filepath);     filename = filenameutils.getbasename(filepath.tostring());     bfolder.uploadfile(stream, filename); 

you need enumerate folders till find subfolder1, create new boxfolder that. (edit compile errors):

boxfolder bfolder = boxfolder.getrootfolder(api); iterator<boxfolder.info> = bfolder.getchildren().iterator(); for(boxfolder.info : it){   if(i.getname().equals(subfolder1)){     boxfolder folder = new boxfolder(api, i.getid());     fileinputstream stream= null;     filepath = "c:\\uploadfile.txt";     stream = new fileinputstream(filepath);     filename = filenameutils.getbasename(filepath.tostring());     folder.uploadfile(stream, filename);     break;   } } 

Comments