Home » OneDrive Move copy create delete file folder

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.

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..).

Read Also:  Laravel 5.8 AJAX Tutorial Example From Scratch

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

Read Also:  Angular DataTable Pagination Searching Sorting in PHP

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. Read Also:  how to create plugin in wordpress with example
  2. Read Also:  Set dynamically Next Page Url Using JQuery DataTable
  3. Read Also:  Ng-Options to Bind DropdownList using Angular Example
  4. Read Also:  Angular 6 Form Validation Example Tutorial
  5. Read Also:  How to Get Current Date & Time in JavaScript
  6. Read Also:  Get minimum key value of array in PHP
  7. Read Also:  install and/or enable a php accelerator (highly recommended)
  8. Read Also:  JavaScript Remove Object from Array
  9. Read Also:  Ng-Options to Bind DropdownList using Angular Example
  10. Read Also:  Angular 6 Form Validation Example Tutorial

Leave a Comment

Your email address will not be published. Required fields are marked *