I would like to move files to another folder when uploading a new version so people have a record of previous files to refer to. drive_mv() worked fine for this in April 2021. Now when I try the same code in the same environment (and I continue with the same rights on the folders), I get the following error:
Error: Client error: (403) Forbidden
A shared drive item must have exactly one parent.
I've also tried this with the overwrite = TRUE parameter, but the same result.
EDIT: Here is sample code:
for(ri in 163:length(recFilterSchools)){
# ri <- 3 # for testing
curSchool <- recFilterSchools[ri]
curFile <- paste0(fileInputPath,curSchool,".xlsx")
fSave <- paste0(curSchool, fReName, fDate)
fSchoolURLS <- google_Fldrs_Results %>% filter(SchoolNum==curSchool, FolderName==tList)
fSchoolURLS_Arch <- google_Fldrs_Results %>% filter(SchoolNum==curSchool, ParentFolder==tList, FolderName=='Archive')
targetDir <- fSchoolURLS$FileURL
targetArch <- fSchoolURLS_Arch$FileURL
parentID <- fSchoolURLS$LocationID
schID <- fSchoolURLS$schID
curMslRow <- msl_Results %>%
filter(SCHOOL_NUMBER==curSchool)
curSchoolName <- curMslRow$School
drID <- drive_get(targetDir, verbose = TRUE)
curFolderContents <- drive_ls(targetDir,
pattern= tList,
type='spreadsheet')
# typeof(curFolderContents)
# fmRows <- nrow(curFolderContents)
fmRows <- nrow(curFolderContents)
if (fmRows>0){
for (fm in 1:nrow(curFolderContents)){
# fm <-1
mvFiles <- drive_mv(file=as_id(curFolderContents$id[fm]),
path=targetArch
,name= curFolderContents$name[fm])
drResources <- mvFiles$drive_resource[[1]]
OutUploadedDF <- rbind(OutUploadedDF, data.frame(stringsAsFactors = FALSE,
FileID = mvFiles$id,
FileName = mvFiles$name,
FilePath = drResources$webViewLink,
FileParent = parentID,
FileType = drResources$mimeType,
DateUploaded = format(Sys.time(),'%m/%d/%Y'),
schID = schID))
}
}
#more code below to upload new file to folder
}
```thanks
I would like to move files to another folder when uploading a new version so people have a record of previous files to refer to. drive_mv() worked fine for this in April 2021. Now when I try the same code in the same environment (and I continue with the same rights on the folders), I get the following error:
Error: Client error: (403) Forbidden
A shared drive item must have exactly one parent.
Run
rlang::last_error()to see where the error occurred.I've also tried this with the overwrite = TRUE parameter, but the same result.
EDIT: Here is sample code: