Inthistutorial, we'regoingtosee a fewdifferentmethodsthatareavailabletousinthedropbox, a p I thatallowustointeractwithfilesandfoldersandmanipulatethem.
MynameisCristian.
I'llbeyourinstructorforthiscourse, and I'm sureyou'rewonderingwhatwe'regonnadoandwhatyouneedtoknow.
Therearemanymoreoptionsavailableinthedropbox a p I manydifferentmethodsyoucanusetomanipulatefilesandfolders, butthesearetheoneswe'regoingtogoover, andhopefullythatwillgiveyou a goodbasisforhowtheFBIgenerallyworks.
Additionally, we'llusesummarymethodsthatmaybeyou'veneverseenbefore, ormaybeneedssomeclarificationhowtheyworkwell, usesome s sixfeaturessuchasAarghfunctions, andwe'lllearnhowtouse a sink a weight, whichis a fairlynewwayofdealingwith a speargunsdataandisperfectforourusecase.
Asforwhatwe'rebuildingspecificallywell, take a lookhereandyou'llseethatwehave a fileorganizer 3000 As I'veaffectionatelynamedit.
Wehave a pathwherewecansearchforfilesorfolders, andwehavethemListenoutherewiththumbnailsattheendofthislesson, willbeabletoorganizeeveryfileinanygivenfolderusingthepathhere, andoncewehitorganized, it'llmovethosefilesintodifferentfoldersbasedontheirdatemodified.
AndifyougoovertomyAPSonthelefthandside, youshouldsee a blankpagebecausemostlikelyyoudon't haveanyAPSyet.
AndthenyoucanclickoncreateAPupatthetop, right?
That'llgetanAPstartedforyou.
Now, before I gofurther, I shouldmentionyoudon't needtodothistotakethiscoursejustgoingtogiveyousomebriefinformationonhowtosetup a napsothatwhenyoudosetup a nap, youcouldbefamiliarwithitanditwillhelpYouknowhow I setupthisapp.
Sofirstisgonnaaskyouwhich a p I youwanttouseforthisapp?
We'reusingtheregularDropbox a p I.
IfyouwantedtosupportteamsforDropboxSomultiplepeoplecollaboratingwithinDropboxthenyoumightslipDropboxbusiness a p I.
OnethingyoumakesureofistosurroundDropboxwithcurlybracesbecausethisis a namedimportorexport, andoncewedothat, wecangoaheadanduseittocreate a classorratherinStan.
Sheate a classandassignitto a verybook.
We'llcallthat B B X forDropbox, andtheywerejustgoingtosaynewandthendropboxwithparenthesesandwe'regonnapassinanobjecttothisfunction, whichiscreating a classforusthatonceagainwe'reassigningto D B X.
Nowthatobjectsgonnataketwoproperties, oneisgonnabeanaccesstoken, andtheotherisgoingtobe a fetchlibrary.
Butifyoujustwanttousethenativewindow, fetchlibrary, thenyoucouldjustput a patchthatusesthesixfeatureofsimplyassumingthatthepropertyandthevariablearethesamelipsthere.
That's funandall, butlet's seeifwecanrenderthingstothebrowser I knowthistutorialismoreaboutdropbox, but I thought I mightbeusefultoseehowwe'remakingthingshappeninthedom.
Here I amdeclaring a variablecalledfinalistLMforElementandusingdocument a CreaseLectertoselectanelementwiththeclassofJsfilelist.
I liketoputday.
It's thebeginningofmyclassnamesjusttoknowthat I'm dealingwithJavaScriptso I don't accidentallymesswiththemwhen I'm justdealingwith a femaleorCSS, we'regonnagoaheadanddo a littlerefactoringheretosetup a rap.
What I'vejustdoneisdeclare a statevariablethatwillholdourstate.
Afterdeclaringourotherfunctions, I'vedeclaredanupdatefilesfunctionwhichwilltakesomefilesandupdatethestateaccordinglysothatwekeepallouroldfilesthatwereinstateaswellasupdatedwiththenewonesandinsidethatwerealsocallingourrenderfilesfunction, whichwillfillinnowinsiderenderfileswillfirstneedtogetourelementsothatwecanplacesome H e mailinthere.
Nowtherearetwothings I wanttodowiththefileshere.
First, I want a sortBenBen.
I want a mapoverthemandforeveryoneofthemcreating l I elementsothatwecanseethelist.
Nextweturntoourdotmapmethod, whichisgonnaloopthrougheveryiteminthearrayandreturnin a rapethemeAtMethodofHonoreaccepts a functionFirstargumentiseachiteminthatarrayinourcase, a fileorfolder?
Infact, let's goaheadandcheckwhattypethisis.
Well, sayCONST.
Typeequalsfile.
Andthen, ifyou'llrecalltheDOTPaigepropertyiswhatstores, whetherit's a fileor a folder, wejustwanttoreturnouractual H e mail.
I'm gonnagoaheadandusebacktickstocreate a temporalliteralinsidethistemple, literal.
Whatever I putwillbewhat's returned.
Itwilltakeitliterally.
Hencethename.
Solet's returnandout I elementandwhatwewanttoseeultimatelyinthebrowseristhenameofthefile.
IfweweretolookatourcouncilagainandseewhatisbeingreturnedfromJohn, Boxwillseethatthere's a dotmainpropertyoneveryfile, sowe'llputthatinthere.
I alsowanttogoaheadanddosomestylingrealquick.
I'vealreadydeclared a classof D B X listitemforeachindividualitemonthelist, andthen I alsowanttoputthetypethatwejustdeclaredabove.
Soweknowifit's a fileorfolder, Okay, now, beforethatactuallycandoanything.
Essentially, whatwewanttodoisjustcreate a thumbnailpropertyoneachfileobjectthatholdsthethumbnaildata.
Thisnextpartgets a littlebitcomplicated, so I'm justgonnagoaheadandpaceitout, andthenwecanwalkthroughitstepbystep.
Firstofall, we'regoingtomake a copyofourcurrentstatethatfiles, Ray, Wedothatveryeasilywiththe E S sixspreadoperatorasthosethreedotshereatthebeginning, that's essentiallytellingJavaScripttospreadtheitemsofthearrayintothis a new, thisnewarray.
Soconcertspeople's awaitwhateverourasynchronouscallislongwasthatreturntopromiseThisshouldworkandwecangetridofheart, thencalledandinsteadactlikethisjust a regularvariable.
Essentially, ifyoupicturethisfunctionbeing a synchronousfunction, we'reworkingwithasynchronousdatathesameway.
It's a ziff.
Weweresayingconstructsequalsoneplustwoandthenusingitjustlikewenormallywhatonlythisfunctionis a sicknessandbyusing a sinkOh, wait.
Ifyoulookatthetool, you'llbeabletoseethedifferentoptionsthatareavailableandyoucanenter a pathandyoucanenter a limit, forexample, andthenyoucangoaheadandsubmitthatcalled.
Onceagain, we'regonnacallit, getmorefilesfunctionthatwestillneedtocreate, gonnapassinthecruiser, andwe'realsogonnapassin a callbackfunctionsothatwhenmorefilesare a treatthosefilescouldbepassedintothisfunction, andwecanupdatefires.
Okay, Now, whenwe'redoingthis, I'd liketoshow a loadingmessagetotheusers.