Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

microsoft graph api - OneDrive. Access to files with a long filename using a path

I have a filename on the root of OneDrive. The filename has a long name, 344 characters below a maximum 400 characters (1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.png). When I try to get an object using a path, I get an error.

{
    "error": {
        "code": "UnknownError",
        "message": "",
        "innerError": {
            "date": "2021-01-28T11:02:35",
            "request-id": "22461ea7-7ef9-4ad8-b945-ff7d3b9694d8",
            "client-request-id": "669fd185-019c-b32e-112b-c52e1732d78f"
        }
    }
}

I'm using C# GraphClient library. How can I work with long filenames using a path?

question from:https://stackoverflow.com/questions/65936330/onedrive-access-to-files-with-a-long-filename-using-a-path

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That name exceeds the 255 characters per segment limitation in OneDrive and SharePoint:

Each segment of the path (a segment is a file name or folder name like “Promotion” or “Some File.xlsx” in the examples above) can't be more than 255 characters due to operating system limitations.

You can get a DriveItem the file by its id:

GET /drives/{drive-id}/items/{item-id}
GET /groups/{group-id}/drive/items/{item-id}
GET /me/drive/items/{item-id}
GET /sites/{site-id}/drive/items/{item-id}
GET /sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem
GET /users/{user-id}/drive/items/{item-id}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...