android - How to save folder in specific folder in Google Drive -
i can save/copy file in folder of google drive using below code .but when apply method save folder in other folder, can't save folder, , nothing happens. want copy folder , save @ place
string locationid="0b-wftscd2afsfs34tc-223";//getting id of parent folder have make new file child file orgnlfile =global_file; file copiedfile = new file(); copiedfile.settitle(orgnlfile.gettitle()); copiedfile.setmimetype(orgnlfile.getmimetype()); copiedfile.setparents(arrays.aslist(new parentreference().setid(locationid))); try { mservice.files().copy(orgnlfile.getid(), copiedfile).execute(); } catch (ioexception e) { system.out.println("an error occurred: " + e); }
but unfortunately doesn't work copy-paste folder in other directory
this because copy duplicating media contents of file new file. since folder has no media contents, there nothing copy.
when "i want copy folder", mean (1) copy only folder, or (2) copy folder , files within folder, , mean (3) duplicate or make second reference?
depending on want achieve, drive api calls need make different.
perhaps best way explain want express in terms of *nix commands "cp", "mv" , "ln"
to create duplicate of folder-a (which under folder-b) , children within folder-c, (in *nix, "cp -r /folder-b/folder-a /folder-c") need :-
- make new folder-a under new parent folder (folder-c). nb although folder-a has same name original. different folder.
- make note of file-id of new folder-a
- get list of children of original folder-a (children feed)
- for each child, copy it
- update parents property of each new file new folder-a
if there folders within folder-a, need above recursively
Comments
Post a Comment