Skip to content

Krizalys Onedrive Proxy DriveItemProxy

Christophe Vidal edited this page Aug 4, 2019 · 1 revision

Krizalys\Onedrive\Proxy\DriveItemProxy

A proxy to a \Microsoft\Graph\Model\DriveItem instance.

Properties

$resourceDefinition

private \Krizalys\Onedrive\Definition\ResourceDefinitionInterface $resourceDefinition
  • Visibility: private

$graph

protected \Microsoft\Graph\Graph $graph
  • Visibility: protected

$entity

protected \Microsoft\Graph\Model\Entity $entity
  • Visibility: protected

$audio

public \Krizalys\Onedrive\Proxy\AudioProxy $audio

The audio.

  • Visibility: public

$content

public \GuzzleHttp\Psr7\Stream $content

The content.

  • Visibility: public

$cTag

public string $cTag

The CTag.

  • Visibility: public

$deleted

public \Krizalys\Onedrive\Proxy\DeletedProxy $deleted

The deleted.

  • Visibility: public

$file

public \Krizalys\Onedrive\Proxy\FileProxy $file

The file.

  • Visibility: public

$fileSystemInfo

public \Krizalys\Onedrive\Proxy\FileSystemInfoProxy $fileSystemInfo

The file system info.

  • Visibility: public

$folder

public \Krizalys\Onedrive\Proxy\FolderProxy $folder

The folder.

  • Visibility: public

$image

public \Krizalys\Onedrive\Proxy\ImageProxy $image

The image.

  • Visibility: public

$location

public \Krizalys\Onedrive\Proxy\GeoCoordinatesProxy $location

The location.

  • Visibility: public

$package

public \Krizalys\Onedrive\Proxy\PackageProxy $package

The package.

  • Visibility: public

$photo

public \Krizalys\Onedrive\Proxy\PhotoProxy $photo

The photo.

  • Visibility: public

$publication

public \Krizalys\Onedrive\Proxy\PublicationFacetProxy $publication

The publication.

  • Visibility: public

$remoteItem

public \Krizalys\Onedrive\Proxy\RemoteItemProxy $remoteItem

The remote item.

  • Visibility: public

$root

public \Krizalys\Onedrive\Proxy\RootProxy $root

The root.

  • Visibility: public

$searchResult

public \Krizalys\Onedrive\Proxy\SearchResultProxy $searchResult

The search result.

  • Visibility: public

$shared

public \Krizalys\Onedrive\Proxy\SharedProxy $shared

The shared.

  • Visibility: public

$sharepointIds

public \Krizalys\Onedrive\Proxy\SharepointIdsProxy $sharepointIds

The SharePoint IDs.

  • Visibility: public

$size

public integer $size

The size.

  • Visibility: public

$specialFolder

public \Krizalys\Onedrive\Proxy\SpecialFolderProxy $specialFolder

The special folder.

  • Visibility: public

$video

public \Krizalys\Onedrive\Proxy\VideoProxy $video

The video.

  • Visibility: public

$webDavUrl

public string $webDavUrl

The WebDAV URL.

  • Visibility: public

$children

public array<mixed,\Krizalys\Onedrive\Proxy\DriveItem> $children

The children.

  • Visibility: public

$listItem

public \Krizalys\Onedrive\Proxy\ListItemProxy $listItem

The list item.

  • Visibility: public

$permissions

public array<mixed,\Krizalys\Onedrive\Proxy\PermissionProxy> $permissions

The permissions.

  • Visibility: public

$thumbnails

public array<mixed,\Krizalys\Onedrive\Proxy\ThumbnailProxy> $thumbnails

The thumbnails.

  • Visibility: public

$versions

public array<mixed,\Krizalys\Onedrive\Proxy\DriveItemVersionProxy> $versions

The versions.

  • Visibility: public

$workbook

public \Krizalys\Onedrive\Proxy\WorkbookProxy $workbook

The workbook.

  • Visibility: public

$createdBy

public \Krizalys\Onedrive\Proxy\IdentitySetProxy $createdBy

The "created by" identity set.

$createdDateTime

public \DateTime $createdDateTime

The created date/time.

$description

public string $description

The description.

$eTag

public string $eTag

The ETag.

$lastModifiedBy

public \Krizalys\Onedrive\Proxy\IdentitySetProxy $lastModifiedBy

The "last modified by" identity set.

$lastModifiedDateTime

public \DateTime $lastModifiedDateTime

The last modified date/time.

$name

public string $name

The name.

$parentReference

public \Krizalys\Onedrive\Proxy\ItemReferenceProxy $parentReference

The parent reference.

$webUrl

public \Krizalys\Onedrive\Proxy\UserProxy $webUrl

The web URL.

$createdByUser

public \Krizalys\Onedrive\Proxy\UserProxy $createdByUser

The "created by" user.

$lastModifiedByUser

public \Krizalys\Onedrive\Proxy\UserProxy $lastModifiedByUser

The "last modified by" user.

$id

public string $id

The ID.

Methods

__construct

mixed Krizalys\Onedrive\Proxy\EntityProxy::__construct(\Microsoft\Graph\Graph $graph, \Microsoft\Graph\Model\Entity $entity)

Constructor.

Arguments

  • $graph Microsoft\Graph\Graph - The Microsoft Graph.
  • $entity Microsoft\Graph\Model\Entity - The entity.

__get

mixed Krizalys\Onedrive\Proxy\EntityProxy::__get(string $name)

Getter.

Arguments

  • $name string - The name.

createFolder

\Krizalys\Onedrive\Proxy\DriveItemProxy Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder(string $name, \Krizalys\Onedrive\Proxy\mixed[string] $options)

Creates a folder under this folder drive item.

This operation is supported only on folders (as opposed to files): it fails if this DriveItemProxy instance does not refer to a folder.

The conflict behavior may be given as an option, for example:

$driveItem->createFolder('folder');
// => Folder 'folder' created under $driveItem.

$childDriveItem1 = $driveItem->createFolder(
    'folder',
    ['conflictBehavior' => ConflictBehavior::RENAME]
);
// => Folder 'folder 1' created under $driveItem.
  • Visibility: public

Arguments

  • $name string - The name.

  • $options Krizalys\Onedrive\Proxy\mixed[string]

    The options. Supported options:

    • 'description' (string): the description of the folder created ;
    • 'conflictBehavior' (string): the conflict behavior.

getChildren

array<mixed,\Krizalys\Onedrive\Proxy\DriveItemProxy> Krizalys\Onedrive\Proxy\DriveItemProxy::getChildren(\Krizalys\Onedrive\Proxy\mixed[string] $options)

Gets this folder drive item's children.

This operation is supported only on folders (as opposed to files): it fails if this DriveItemProxy instance does not refer to a folder.

The retrieved result set may be refined via the $options parameter. For example, to retrieve the first ten children sorted by name in descending order:

$childDriveItems = $driveItem->getChildren([
    'top' => 10,
    'orderBy' => [
        ['name', 'desc'],
    ],
]);
  • Visibility: public

Arguments

  • $options Krizalys\Onedrive\Proxy\mixed[string]

    The options. Supported options:

    • 'top' (number): The number of items to retrieve. Default: 200 ;
    • 'orderBy' (string[][]): The list of property-direction tuples to use to sort retrieved items. Each tuple consists of a property and a direction, separated from each other by whitespace. Although the official OneDrive documentation claims to support sorting by multiple properties, we did not acknowledge this behavior, yet, and instead got Bad Request errors from the OneDrive API. We do not recommend relying on this feature. This option anticipates a related change in the OneDrive API and is designed to support this feature without introducing breaking changes. Supported properties:

delete

mixed Krizalys\Onedrive\Proxy\DriveItemProxy::delete()

Deletes this drive item.

  • Visibility: public

upload

\Krizalys\Onedrive\Proxy\DriveItemProxy Krizalys\Onedrive\Proxy\DriveItemProxy::upload(string $name, string|resource|\GuzzleHttp\Psr7\Stream $content, \Krizalys\Onedrive\Proxy\mixed[string] $options)

Uploads a file under this folder drive item.

This operation is supported only on folders (as opposed to files): it fails if this DriveItemProxy instance does not refer to a folder.

The conflict behavior and the MIME type of the drive item may be given as options, for example:

$driveItem->upload(
    'file.txt',
    'Some content',
    ['contentType' => 'text/plain']
);
// => Text file 'file.txt' created under $driveItem.

$childDriveItem1 = $driveItem->upload(
    'file.txt',
    'Some other content',
    [
        'conflictBehavior' => ConflictBehavior::RENAME,
        'contentType'      => 'text/plain',
    ]
);
// => Text file 'file 1.txt' created under $driveItem.
  • Visibility: public

Arguments

  • $name string - The name.

  • $content string|resource|GuzzleHttp\Psr7\Stream - The content.

  • $options Krizalys\Onedrive\Proxy\mixed[string]

    The options. Supported options:

    • 'conflictBehavior' (string): the conflict behavior ;
    • 'contentType' (string): the MIME type of the uploaded file.

startUpload

\Krizalys\Onedrive\Proxy\UploadSessionProxy Krizalys\Onedrive\Proxy\DriveItemProxy::startUpload(string $name, string|resource|\GuzzleHttp\Psr7\Stream $content, \Krizalys\Onedrive\Proxy\mixed[string] $options)

Creates an upload session to upload a large file in multiple ranges under this folder drive item.

This operation is supported only on folders (as opposed to files): it fails if this DriveItemProxy instance does not refer to a folder.

Uploading files using this method involves two steps: 1. first, create the upload session for a given file using this method ; 2. then, complete it using complete() on the instance it returns.

For example:

$driveItem->upload(
    'file.txt',
    'Some content',
    ['contentType' => 'text/plain']
);
// => Text file 'file.txt' created under $driveItem.

$uploadSession1 = $driveItem->startUpload(
    'file.txt',
    'Some other content',
    [
        'conflictBehavior' => ConflictBehavior::RENAME,
        'type'             => 'text/plain',
    ]
);

$childDriveItem = $uploadSession1->complete();
// => Text file 'file 1.txt' created under $driveItem.
  • Visibility: public

Arguments

  • $name string - The name.
  • $content string|resource|GuzzleHttp\Psr7\Stream - The content.
  • $options Krizalys\Onedrive\Proxy\mixed[string] - The options. See UploadSession::__construct for supported options.

download

\GuzzleHttp\Psr7\Stream Krizalys\Onedrive\Proxy\DriveItemProxy::download()

Downloads this file drive item.

This operation is supported only on files (as opposed to folders): it fails if this DriveItemProxy instance does not refer to a file.

  • Visibility: public

rename

\Krizalys\Onedrive\Proxy\DriveItemProxy Krizalys\Onedrive\Proxy\DriveItemProxy::rename(string $name, \Krizalys\Onedrive\Proxy\mixed[string] $options)

Renames this drive item.

When renaming a drive item, its description may also be changed.

$driveItem = $driveItem->rename(
    'new-name.txt',
    ['description' => 'New description']
);
  • Visibility: public

Arguments

  • $name string - The name.

  • $options Krizalys\Onedrive\Proxy\mixed[string]

    The options. Supported options:

    • 'description' (string): the new description to set after the drive item is renamed.

move

\Krizalys\Onedrive\Proxy\DriveItemProxy Krizalys\Onedrive\Proxy\DriveItemProxy::move(\Krizalys\Onedrive\Proxy\DriveItemProxy $destinationItem, \Krizalys\Onedrive\Proxy\mixed[string] $options)

Moves this drive item.

The $destinationItem instance must refer to a folder.

When moving a drive item, its name may also be changed.

$driveItem = $driveItem->move(
    $parentDriveitem,
    ['name' => 'new-name.txt']
);
  • Visibility: public

Arguments

  • $destinationItem Krizalys\Onedrive\Proxy\DriveItemProxy - The destination item.

  • $options Krizalys\Onedrive\Proxy\mixed[string]

    The options. Supported options:

    • 'name' (string): the new name to set after the drive item is moved.

copy

string Krizalys\Onedrive\Proxy\DriveItemProxy::copy(\Krizalys\Onedrive\Proxy\DriveItemProxy $destinationItem, \Krizalys\Onedrive\Proxy\mixed[string] $options)

Copies this file drive item.

This operation is supported only on files (as opposed to folders): it fails if this DriveItemProxy instance does not refer to a file.

Additionally, the $destinationItem instance must refer to a folder.

When copying a file, the name of the copy may also be changed. A new name is required if copying to the same folder.

$driveItem = $driveItem->copy(
    $parentDriveitem,
    ['name' => 'new-name.txt']
);

Copying folders is not directly supported by OneDrive. To copy a whole folder and its children, applications can explicitly create an empty folder, using createFolder(), and copy the children from the original folder to the new folder, using copy(). This process can be repeated recursively if support for multiple levels of children is needed.

  • Visibility: public

Arguments

  • $destinationItem Krizalys\Onedrive\Proxy\DriveItemProxy - The destination item.

  • $options Krizalys\Onedrive\Proxy\mixed[string]

    The options. Supported options:

    • 'name' (string): the name of the copied file.

createLink

\Krizalys\Onedrive\Proxy\PermissionProxy Krizalys\Onedrive\Proxy\DriveItemProxy::createLink(string $type, \Krizalys\Onedrive\Proxy\mixed[string] $options)

Creates a sharing link to this drive item.

See SharingLinkType for supported values for the parameter $type.

See SharingLinkScope for supported values for the option 'scope'.

  • Visibility: public

Arguments

  • $type string - The type.

  • $options Krizalys\Onedrive\Proxy\mixed[string]

    The options. Supported values:

    • 'scope' (string): the scope.

invite

array<mixed,\Krizalys\Onedrive\Proxy\PermissionProxy> Krizalys\Onedrive\Proxy\DriveItemProxy::invite(array<mixed,string> $recipients, array<mixed,string> $roles, \Krizalys\Onedrive\Proxy\mixed[string] $options)

Creates a sharing invitation to this drive item.

See Role for supported values for the parameter $roles.

A custom message, the sign in requirement, and the send invitation option may be given as options. For example, to invite 2 users to get read and write permissions on a given drive item, send them an invitation email with a custom message, and require them sign in to access the drive item:

$driveItem->invite(
    [
        'user1@example.com',
        'user2@example.com',
    ],
    [
        Role::READ,
        Role::WRITE,
    ],
    [
        'message'        => 'Custom invitation message',
        'requireSignIn'  => true,
        'sendInvitation' => true,
    ]
);
  • Visibility: public

Arguments

  • $recipients array<mixed,string> - The recipients.
  • $roles array<mixed,string> - The roles.
  • $options Krizalys\Onedrive\Proxy\mixed[string] - The options.
Clone this wiki locally