Upload file to users onedrive under same domain

Rehmuk 0 Reputation points
2023-03-31T22:53:44.2466667+00:00

we want to develop a web app from which we can upload files to student's one driver under our Azure domain ( Iwht out student credentials).

for this we need a list of all students, then we upload particular files to each student depending upon their classes as per our internal data.

Is there any way can achieve this.

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,301 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,918 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,266 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,142 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,822 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ed Harris 25 Reputation points
    2023-04-03T02:03:10.02+00:00

    Register your web app in the Azure AD and grant it the necessary permissions to access OneDrive for Business and SharePoint files and folders. Then, you can use the Microsoft Graph API to get a list of all students in your Azure domain and upload files to their OneDrive for Business accounts.

    Here’s an example of how you can use the Microsoft Graph API to upload a file to a user’s OneDrive for Business account:

    const options = {

    authProvider,

    };

    const client = Client.init(options);

    const file = {

    name: "myfile.txt",

    content: "This is the content of the file"

    };

    const response = await client.api('/users/{user-id}/drive/root/children')

    .post(file);

    You can find more information about using the Microsoft Graph API to interact with OneDrive for Business and SharePoint files and folders at https://docs.microsoft.com/en-us/graph/onedrive-concept-overview

    Hope this helps!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.