OneDrive Move copy create delete file folder

OneDrive Move copy create delete file folder

Today, We want to share with you OneDrive Move copy create delete file folder.
In this post we will show you Move, copy, create, or delete a file or folder on OneDrive, hear for OneDrive Copying and Moving Files and Folders we will give you demo and example for implement.
In this post, we will learn about How to copy or move files to OneDrive with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

If you are using onedrive Microsoft Office account on your website,iPad or iPhone and android application,
you may have to noticed to that there is not simple or easy way to rename file and folder,
re-arrange data and simple organize your all files and content within the PowerPoint,
Excel sheet and Word sheet application.

Create a new folder in OneDrive

Creating folders and files to group and classify your all files is key with staying organized.
and This is especially most important when you all start working on your files or folder on multiple devices (laptop,work computer, Android,home computer, smartPhone, iPad, iPhone,etc..).

Creating a new folder HTTP request using POST Method

//using parent folder id and sub children name
POST /drive/items/{parent-id}/children

Example : Creating a new folder using OneDrive

//provid folder or file name
POST /drive/root/children //method post
Content-Type: application/json // header send data

{
  "name": "pakainfo",
  "folder": { }
}

Response

HTTP/1.1 201 Created //error message
Content-type: application/json //// header send data

{
  "id": "0123456789abc",
  "name": "pakainfo",
  "folder": { "childCount": 0 }
}

Delete an File and folder in OneDrive

Deleting a File and folder HTTP request using DELETE Method

DELETE /drive/items/{item-id}
DELETE /drive/root:/{item-path}

Example : Deleting a File and folder using OneDrive

DELETE /drive/items/{item-id} //using item-id delete

Response

HTTP/1.1 204 No Content //Success http code

Download a OneDrive File and Folder contents

downloadong a File and folder HTTP request using GET Method

GET /drive/items/{item-id}/content //using item-id it
GET /drive/root:/{path and filename}:/content //using item content path

Example :downloadong a File and folder using OneDrive

GET /drive/items/{item-id}/content 
//using item-id it

Response

HTTP/1.1 302 Found // Error generate
Location: https://b0mpua-by3301.files.1drv.com/z23vmagjang4tehasghasodfik

Copy an Folder and File on OneDrive

Copying a File and folder HTTP request using POST Method

POST /drive/items/{item-id}/action.copy // using id to copy
POST /drive/root:/{item-path}:/action.copy // using path to copy

Example : Copying a File and folder using OneDrive

POST /drive/items/{item-id}/action.copy // using id to copy
Content-Type: application/json // using path to copy
Prefer: respond-async  //  type sync or async

{
  "parentReference": {
    "id": "{new-parent-id}", // folder parent id
    "path": "/drive/root:/Documents" //base path
  },
  "name": "resfoobardata.txt"
}

Response

HTTP/1.1 202 Accepted //http header code
Location: https://onedrive.com/monitor/z6512jlkjlng5852abcastrg

Get Fetch data for a OneDrive Files and Folder

fetching a File and folder HTTP request using GET Method

GET /drive/items/{item-id} // fetching id to get data
GET /drive/root:/{item-path} // fetching path to get data

Example : fetching a File and folder using OneDrive

GET /drive/items/{item-id} // fetching id to get data

Response

HTTP/1.1 200 OK
Content-type: application/json

{
  "id": "05895456789abc",
  "name": "pakainfoexample.xlsx",
  "eTag": "9898918JKOMH2jlkda",
  "cTag": "Ja585klkas55ssidj1l2j34l98Ale",
  "createdBy": { "user": { "id": "9898", "displayName": "admin pakainfo" } },
  "createdDateTime": "string (timestamp)",
  "lastModifiedBy": { "user": { "id": "9898", "displayName": "pakainfo admin" } },
  "lastModifiedDateTime": "string (timestamp)",
  "size": 9898,
  "webUrl": "http://onedrive.com/...",
  "parentReference": { "driveId": "98985", "id": "root", "path": "/drive/root:" },
  "folder": { "childCount": 6 }
}

Uploading contents for an File and Folder on OneDrive

1st : Simple item upload – It is less than 100MB of content.

2nd : Resumable item upload – It is resumable transfer data.

3rd : Multipart item upload – It is upload data files or both the contents of an files/folder and metadata.

4th : Upload from URL (preview) – It is file and folder can be retrieved.(content)


Related FAQ

Here are some more FAQ related to this Article:

  1.   Fadein Fadeout example using Jquery Example
  2.   Angular 6 JSON Array Merge into one array
  3.   C# nested while loops and multiple conditions
  4.   Angular 6 Image Upload with Validation Example
  5.   php array remove keys keep values example
  6.   DataTable Custom Filter Server Side Examples
  7.   Hide Uncategorized category from WooCommerce
  8.   Allow Only Numbers in TextBox Windows Forms using regular expression
  9.   PHP access global variable in function
  10.   PHP cURL Multiple Asynchronous Http Requests