命名空间:microsoft.graph
创建新的 fileStorageContainer 对象。
containerTypeId 标识的容器类型必须在租户中注册。
对于委托调用,调用用户设置为 fileStorageContainer 的所有者。
此 API 可用于以下国家级云部署。
全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
✅ |
✅ |
✅ |
✅ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
权限类型 |
最低特权权限 |
更高特权权限 |
委派(工作或学校帐户) |
FileStorageContainer.Selected |
不可用。 |
委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
应用程序 |
FileStorageContainer.Selected |
不可用。 |
除了Microsoft Graph 权限外,应用还必须具有调用此 API 所需的容器类型级别权限。 有关容器类型的详细信息,请参阅 容器类型。 若要详细了解容器类型级别权限,请参阅 SharePoint 嵌入式授权。
HTTP 请求
POST /storage/fileStorage/containers
可选的查询参数
此方法支持以下 OData 查询参数来帮助自定义响应。 若要了解一般信息,请参阅 OData 查询参数。
名称 |
说明 |
dataLocation |
指定在多地理位置租户中创建容器所需的数据位置。 省略 $dataLocation 请求中的 参数会在租户的默认位置创建容器。 有关详细信息,请参阅 可用的多地理位置区域及其位置代码。 |
名称 |
说明 |
Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
Content-Type |
application/json. 必需。 |
请求正文
在请求正文中,提供 fileStorageContainer 对象的 JSON 表示形式。
创建 fileStorageContainer 时,可以指定以下属性。
属性 |
类型 |
说明 |
displayName |
String |
容器的显示名称。 必需。 |
description |
String |
容器的用户可见说明。 可选。 |
containerTypeId |
GUID |
容器实例的容器类型。 必填。 |
settings |
fileStorageContainerSettings |
与容器关联的设置。 可选。 |
响应
如果成功,此方法在 201 Created
响应正文中返回响应代码和 fileStorageContainer 对象。
示例
请求
以下示例演示如何创建 fileStorageContainer。
POST https://graph.microsoft.com/v1.0/storage/fileStorage/containers
Content-Type: application/json
{
"displayName": "My Application Storage Container",
"description": "Description of My Application Storage Container",
"containerTypeId": "91710488-5756-407f-9046-fbe5f0b4de73",
"settings": {
"isOcrEnabled": true
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new FileStorageContainer
{
DisplayName = "My Application Storage Container",
Description = "Description of My Application Storage Container",
ContainerTypeId = Guid.Parse("91710488-5756-407f-9046-fbe5f0b4de73"),
Settings = new FileStorageContainerSettings
{
IsOcrEnabled = true,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Storage.FileStorage.Containers.PostAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
mgc storage file-storage containers create --body '{\
"displayName": "My Application Storage Container",\
"description": "Description of My Application Storage Container",\
"containerTypeId": "91710488-5756-407f-9046-fbe5f0b4de73",\
"settings": {\
"isOcrEnabled": true\
}\
}\
'
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
"github.com/google/uuid"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewFileStorageContainer()
displayName := "My Application Storage Container"
requestBody.SetDisplayName(&displayName)
description := "Description of My Application Storage Container"
requestBody.SetDescription(&description)
containerTypeId := uuid.MustParse("91710488-5756-407f-9046-fbe5f0b4de73")
requestBody.SetContainerTypeId(&containerTypeId)
settings := graphmodels.NewFileStorageContainerSettings()
isOcrEnabled := true
settings.SetIsOcrEnabled(&isOcrEnabled)
requestBody.SetSettings(settings)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
containers, err := graphClient.Storage().FileStorage().Containers().Post(context.Background(), requestBody, nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
FileStorageContainer fileStorageContainer = new FileStorageContainer();
fileStorageContainer.setDisplayName("My Application Storage Container");
fileStorageContainer.setDescription("Description of My Application Storage Container");
fileStorageContainer.setContainerTypeId(UUID.fromString("91710488-5756-407f-9046-fbe5f0b4de73"));
FileStorageContainerSettings settings = new FileStorageContainerSettings();
settings.setIsOcrEnabled(true);
fileStorageContainer.setSettings(settings);
FileStorageContainer result = graphClient.storage().fileStorage().containers().post(fileStorageContainer);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const fileStorageContainer = {
displayName: 'My Application Storage Container',
description: 'Description of My Application Storage Container',
containerTypeId: '91710488-5756-407f-9046-fbe5f0b4de73',
settings: {
isOcrEnabled: true
}
};
await client.api('/storage/fileStorage/containers')
.post(fileStorageContainer);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\FileStorageContainer;
use Microsoft\Graph\Generated\Models\FileStorageContainerSettings;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new FileStorageContainer();
$requestBody->setDisplayName('My Application Storage Container');
$requestBody->setDescription('Description of My Application Storage Container');
$requestBody->setContainerTypeId('91710488-5756-407f-9046-fbe5f0b4de73');
$settings = new FileStorageContainerSettings();
$settings->setIsOcrEnabled(true);
$requestBody->setSettings($settings);
$result = $graphServiceClient->storage()->fileStorage()->containers()->post($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.file_storage_container import FileStorageContainer
from msgraph.generated.models.file_storage_container_settings import FileStorageContainerSettings
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = FileStorageContainer(
display_name = "My Application Storage Container",
description = "Description of My Application Storage Container",
container_type_id = UUID("91710488-5756-407f-9046-fbe5f0b4de73"),
settings = FileStorageContainerSettings(
is_ocr_enabled = True,
),
)
result = await graph_client.storage.file_storage.containers.post(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.type": "#microsoft.graph.fileStorageContainer",
"id": "b!ISJs1WRro0y0EWgkUYcktDa0mE8zSlFEqFzqRn70Zwp1CEtDEBZgQICPkRbil_5Z",
"displayName": "My Application Storage Container",
"description": "Description of My Application Storage Container",
"containerTypeId": "91710488-5756-407f-9046-fbe5f0b4de73",
"status": "inactive",
"createdDateTime": "2021-11-24T15:41:52.347Z",
"settings": {
"isOcrEnabled": false,
"itemMajorVersionLimit": 50,
"isItemVersioningEnabled": true
}
}