6
6
from office365 .runtime .resource_path import ResourcePath
7
7
from office365 .onedrive .baseItem import BaseItem
8
8
from office365 .onedrive .listItem import ListItem
9
- from office365 . runtime . resource_path_url import ResourcePathUrl
9
+
10
10
11
11
12
12
class DriveItem (BaseItem ):
@@ -16,34 +16,34 @@ class DriveItem(BaseItem):
16
16
def create_upload_session (self , item ):
17
17
"""Creates a temporary storage location where the bytes of the file will be saved until the complete file is
18
18
uploaded. """
19
+ result = ClientResult (UploadSession ())
19
20
qry = ServiceOperationQuery (self ,
20
21
"createUploadSession" ,
21
22
None ,
22
23
{
23
24
"item" : item
24
- }
25
+ },
26
+ None ,
27
+ result
25
28
)
26
- result = ClientResult (UploadSession ())
27
- self .context .add_query (qry , result )
29
+ self .context .add_query (qry )
28
30
return result
29
31
30
32
def upload (self , name , content ):
31
33
"""The simple upload API allows you to provide the contents of a new file or update the contents of an
32
34
existing file in a single API call. This method only supports files up to 4MB in size. """
33
- drive_item = DriveItem (self .context , ResourcePathUrl (self .context , self .resourcePath , name ))
34
35
from office365 .graphClient import UploadContentQuery
35
- qry = UploadContentQuery (drive_item , content )
36
- self .context .add_query (qry , drive_item )
37
- return drive_item
36
+ qry = UploadContentQuery (self , name , content )
37
+ self .context .add_query (qry )
38
+ return qry . returnType
38
39
39
40
def download (self ):
40
41
"""Download the contents of the primary stream (file) of a DriveItem. Only driveItems with the file property
41
42
can be downloaded. """
42
43
from office365 .graphClient import DownloadContentQuery
43
44
qry = DownloadContentQuery (self )
44
- result = ClientResult (None )
45
- self .context .add_query (qry , result )
46
- return result
45
+ self .context .add_query (qry )
46
+ return qry .returnType
47
47
48
48
def create_folder (self , name ):
49
49
"""Create a new folder or DriveItem in a Drive with a specified parent item or path."""
@@ -54,56 +54,59 @@ def create_folder(self, name):
54
54
"folder" : {},
55
55
"@microsoft.graph.conflictBehavior" : ConflictBehavior .Rename
56
56
}
57
- qry = CreateEntityQuery (self .children , payload )
58
- self .context .add_query (qry , drive_item )
57
+ qry = CreateEntityQuery (self .children , payload , drive_item )
58
+ self .context .add_query (qry )
59
59
return drive_item
60
60
61
61
def convert (self , format_name ):
62
62
"""Converts the contents of an item in a specific format"""
63
63
from office365 .graphClient import DownloadContentQuery
64
64
qry = DownloadContentQuery (self , format_name )
65
- result = ClientResult (None )
66
- self .context .add_query (qry , result )
67
- return result
65
+ self .context .add_query (qry )
66
+ return qry .returnType
68
67
69
68
def copy (self , name , parent_reference = None ):
70
69
"""Asynchronously creates a copy of an driveItem (including any children), under a new parent item or with a
71
70
new name. """
71
+ result = ClientResult (None )
72
72
qry = ServiceOperationQuery (self ,
73
73
"copy" ,
74
74
None ,
75
75
{
76
76
"name" : name ,
77
77
"parentReference" : parent_reference
78
- }
78
+ },
79
+ None ,
80
+ result
79
81
)
80
- result = ClientResult (None )
81
- self .context .add_query (qry , result )
82
+ self .context .add_query (qry )
82
83
return result
83
84
84
85
def move (self , name , parent_reference = None ):
85
86
"""To move a DriveItem to a new parent item, your app requests to update the parentReference of the DriveItem
86
87
to move. """
87
88
from office365 .graphClient import ReplaceMethodQuery
89
+ result = ClientResult (None )
88
90
qry = ReplaceMethodQuery (self ,
89
91
"move" ,
90
92
None ,
91
93
{
92
94
"name" : name ,
93
95
"parentReference" : parent_reference
94
- }
96
+ },
97
+ None ,
98
+ result
95
99
)
96
- result = ClientResult (None )
97
- self .context .add_query (qry , result )
100
+ self .context .add_query (qry )
98
101
return result
99
102
100
103
def search (self , query_text ):
101
104
"""Search the hierarchy of items for items matching a query. You can search within a folder hierarchy,
102
105
a whole drive, or files shared with the current user. """
103
106
from office365 .graphClient import SearchQuery
104
- qry = SearchQuery (self , query_text )
105
107
result = ClientResult (None )
106
- self .context .add_query (qry , result )
108
+ qry = SearchQuery (self , query_text , result )
109
+ self .context .add_query (qry )
107
110
return result
108
111
109
112
@property
0 commit comments