Skip to content

Commit

Permalink
legacy urls for nested files
Browse files Browse the repository at this point in the history
Use the full relative path for files that may be nested within several folders

closes #1515
  • Loading branch information
TangoYankee committed Apr 19, 2024
1 parent 4be32b6 commit cb2766c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions server/src/sharepoint/sharepoint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,22 @@ export class SharepointService {
}

async getSharepointFileId(driveId: string, relativeUrl: string) {
const filePath = relativeUrl.split("/");
if (filePath.length < 2)
const filePathSegments = relativeUrl.split("/");
const filePathSegmentsCount = filePathSegments.length;
if (filePathSegmentsCount < 4)
throw new HttpException(
{
code: "DISPOSITION_ID_PATH",
title: "Disposition ID Path Error"
},
HttpStatus.BAD_REQUEST
);
const folderName = filePath[filePath.length - 2];
const fileName = filePath[filePath.length - 1];

const fileName = filePathSegments[filePathSegmentsCount - 1];
// A file may be nested within several folders. We rejoin the folders into the relative path
const folderName = filePathSegments
.slice(2, filePathSegmentsCount - 1)
.join("/");

const { accessToken } = await this.msalProvider.getGraphClientToken();
const url = `${
Expand Down

0 comments on commit cb2766c

Please sign in to comment.