File tree Expand file tree Collapse file tree 1 file changed +20
-18
lines changed
libs/labelbox/src/labelbox/schema Expand file tree Collapse file tree 1 file changed +20
-18
lines changed Original file line number Diff line number Diff line change @@ -107,11 +107,14 @@ def upload_members(
107107 # Reset pointer to start of stream
108108 buffer .seek (0 )
109109
110- multipart_file_field = "1"
110+ # Use 0-based indexing as per common convention
111+ multipart_file_field = "0"
111112 gql_file_field = "file"
113+
114+ # Prepare the file content
112115 files = {
113116 multipart_file_field : (
114- f" { multipart_file_field } .csv" ,
117+ "members .csv" , # More descriptive filename
115118 buffer ,
116119 "text/csv" ,
117120 )
@@ -128,25 +131,24 @@ def upload_members(
128131 }
129132 }
130133 """
131- params = {
132- "roleId" : role_id ,
133- gql_file_field : None ,
134- "where" : {"id" : group_id },
134+ # Construct the multipart request following the spec
135+ operations = {
136+ "query" : query ,
137+ "variables" : {
138+ "roleId" : role_id ,
139+ gql_file_field : None , # Placeholder for file
140+ "where" : {"id" : group_id },
141+ },
135142 }
136143
144+ # Map file to the variable
145+ map_data = {multipart_file_field : [f"variables.{ gql_file_field } " ]}
146+
137147 request_data = {
138- "operations" : json .dumps (
139- {
140- "variables" : params ,
141- "query" : query ,
142- }
143- ),
144- "map" : (
145- None ,
146- json .dumps (
147- {multipart_file_field : [f"variables.{ gql_file_field } " ]}
148- ),
149- ),
148+ "operations" : json .dumps (operations ),
149+ "map" : json .dumps (
150+ map_data
151+ ), # Remove the unnecessary (None, ...) tuple
150152 }
151153
152154 client = self .client
You can’t perform that action at this time.
0 commit comments