Class FilesResource
The "files" collection of methods.
Inheritance
Inherited Members
Namespace: Google.Apis.Drive.v2
Assembly: Google.Apis.Drive.v2.dll
Syntax
public class FilesResource
Constructors
FilesResource(IClientService)
Constructs a new resource.
Declaration
public FilesResource(IClientService service)
Parameters
| Type | Name | Description |
|---|---|---|
| IClientService | service |
Methods
Copy(File, string)
Creates a copy of the specified file. Folders cannot be copied.
Declaration
public virtual FilesResource.CopyRequest Copy(File body, string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| File | body | The body of the request. |
| string | fileId | The ID of the file to copy. |
Returns
| Type | Description |
|---|---|
| FilesResource.CopyRequest |
Delete(string)
Permanently deletes a file by ID. Skips the trash. The currently authenticated user must own the file or be an organizer on the parent for shared drive files.
Declaration
public virtual FilesResource.DeleteRequest Delete(string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileId | The ID of the file to delete. |
Returns
| Type | Description |
|---|---|
| FilesResource.DeleteRequest |
EmptyTrash()
Permanently deletes all of the user's trashed files.
Declaration
public virtual FilesResource.EmptyTrashRequest EmptyTrash()
Returns
| Type | Description |
|---|---|
| FilesResource.EmptyTrashRequest |
Export(string, string)
Exports a Google Workspace document to the requested MIME type and returns exported byte content. Note that the exported content is limited to 10MB.
Declaration
public virtual FilesResource.ExportRequest Export(string fileId, string mimeType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileId | The ID of the file. |
| string | mimeType | The MIME type of the format requested for this export. |
Returns
| Type | Description |
|---|---|
| FilesResource.ExportRequest |
GenerateIds()
Generates a set of file IDs which can be provided in insert or copy requests.
Declaration
public virtual FilesResource.GenerateIdsRequest GenerateIds()
Returns
| Type | Description |
|---|---|
| FilesResource.GenerateIdsRequest |
Get(string)
Gets a file's metadata or content by ID.
Declaration
public virtual FilesResource.GetRequest Get(string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileId | The ID for the file in question. |
Returns
| Type | Description |
|---|---|
| FilesResource.GetRequest |
Insert(File)
Insert a new file.
Declaration
public virtual FilesResource.InsertRequest Insert(File body)
Parameters
| Type | Name | Description |
|---|---|---|
| File | body | The body of the request. |
Returns
| Type | Description |
|---|---|
| FilesResource.InsertRequest |
Insert(File, Stream, string)
Insert a new file.
Declaration
public virtual FilesResource.InsertMediaUpload Insert(File body, Stream stream, string contentType)
Parameters
| Type | Name | Description |
|---|---|---|
| File | body | The body of the request. |
| System.IO.Stream | stream | The stream to upload. See remarks for further information. |
| string | contentType | The content type of the stream to upload. |
Returns
| Type | Description |
|---|---|
| FilesResource.InsertMediaUpload |
Remarks
Considerations regarding stream:
-
If
streamis seekable, then the stream position will be reset to0before reading commences. Ifstreamis not seekable, then it will be read from its current position -
Caller is responsible for maintaining the
streamopen until the upload is completed - Caller is responsible for closing the
stream
List()
Lists the user's files.
Declaration
public virtual FilesResource.ListRequest List()
Returns
| Type | Description |
|---|---|
| FilesResource.ListRequest |
ListLabels(string)
Lists the labels on a file.
Declaration
public virtual FilesResource.ListLabelsRequest ListLabels(string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileId | The ID of the file. |
Returns
| Type | Description |
|---|---|
| FilesResource.ListLabelsRequest |
ModifyLabels(ModifyLabelsRequest, string)
Modifies the set of labels on a file.
Declaration
public virtual FilesResource.ModifyLabelsRequest ModifyLabels(ModifyLabelsRequest body, string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| ModifyLabelsRequest | body | The body of the request. |
| string | fileId | The ID of the file for which the labels are modified. |
Returns
| Type | Description |
|---|---|
| FilesResource.ModifyLabelsRequest |
Patch(File, string)
Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might change automatically, such as modifiedDate. This method supports patch semantics.
Declaration
public virtual FilesResource.PatchRequest Patch(File body, string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| File | body | The body of the request. |
| string | fileId | The ID of the file to update. |
Returns
| Type | Description |
|---|---|
| FilesResource.PatchRequest |
Touch(string)
Set the file's updated time to the current server time.
Declaration
public virtual FilesResource.TouchRequest Touch(string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileId | The ID of the file to update. |
Returns
| Type | Description |
|---|---|
| FilesResource.TouchRequest |
Trash(string)
Moves a file to the trash. The currently authenticated user must own the file or be at least a fileOrganizer on the parent for shared drive files. Only the owner may trash a file. The trashed item is excluded from all files.list responses returned for any user who does not own the file. However, all users with access to the file can see the trashed item metadata in an API response. All users with access can copy, download, export, and share the file.
Declaration
public virtual FilesResource.TrashRequest Trash(string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileId | The ID of the file to trash. |
Returns
| Type | Description |
|---|---|
| FilesResource.TrashRequest |
Untrash(string)
Restores a file from the trash. The currently authenticated user must own the file or be at least a fileOrganizer on the parent for shared drive files. Only the owner may untrash a file.
Declaration
public virtual FilesResource.UntrashRequest Untrash(string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileId | The ID of the file to untrash. |
Returns
| Type | Description |
|---|---|
| FilesResource.UntrashRequest |
Update(File, string)
Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might be changed automatically, such as modifiedDate. This method supports patch semantics.
Declaration
public virtual FilesResource.UpdateRequest Update(File body, string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| File | body | The body of the request. |
| string | fileId | The ID of the file to update. |
Returns
| Type | Description |
|---|---|
| FilesResource.UpdateRequest |
Update(File, string, Stream, string)
Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might be changed automatically, such as modifiedDate. This method supports patch semantics.
Declaration
public virtual FilesResource.UpdateMediaUpload Update(File body, string fileId, Stream stream, string contentType)
Parameters
| Type | Name | Description |
|---|---|---|
| File | body | The body of the request. |
| string | fileId | The ID of the file to update. |
| System.IO.Stream | stream | The stream to upload. See remarks for further information. |
| string | contentType | The content type of the stream to upload. |
Returns
| Type | Description |
|---|---|
| FilesResource.UpdateMediaUpload |
Remarks
Considerations regarding stream:
-
If
streamis seekable, then the stream position will be reset to0before reading commences. Ifstreamis not seekable, then it will be read from its current position -
Caller is responsible for maintaining the
streamopen until the upload is completed - Caller is responsible for closing the
stream
Watch(Channel, string)
Subscribes to changes to a file. While you can establish a channel for changes to a file on a shared drive, a change to a shared drive file won't create a notification.
Declaration
public virtual FilesResource.WatchRequest Watch(Channel body, string fileId)
Parameters
| Type | Name | Description |
|---|---|---|
| Channel | body | The body of the request. |
| string | fileId | The ID for the file in question. |
Returns
| Type | Description |
|---|---|
| FilesResource.WatchRequest |