mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
use second request for paging instead of expand children
This commit is contained in:
+14
-4
@@ -112,15 +112,25 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
}
|
||||
|
||||
// Normal query selecting and expanding every children in current directory
|
||||
const { data } = await axios.get(requestUrl, {
|
||||
// Querying current path identity (file or folder) and follow up query childrens in folder
|
||||
const { data: identityData } = await axios.get(requestUrl, {
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
params: {
|
||||
select: '@microsoft.graph.downloadUrl,name,size,id,lastModifiedDateTime,folder,file',
|
||||
expand: 'children(select=@content.downloadUrl,name,lastModifiedDateTime,eTag,size,id,folder,file)',
|
||||
},
|
||||
})
|
||||
res.status(200).json({ path, data })
|
||||
|
||||
if ('folder' in identityData) {
|
||||
const { data: folderData } = await axios.get(`${requestUrl}:/children`, {
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
params: {
|
||||
select: '@microsoft.graph.downloadUrl,name,size,id,lastModifiedDateTime,folder,file',
|
||||
},
|
||||
})
|
||||
res.status(200).json({ path, identityData, folderData })
|
||||
return
|
||||
}
|
||||
res.status(200).json({ path, identityData })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user