File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,27 @@ for page in response.iter_pages():
140140 yield page
141141```
142142
143+ ## File Uploads
144+
145+ Files are uploaded with the [ File] ( ./src/square/core/file.py ) type, which is constructed as a tuple in
146+ a variety of formats. You can customize the filename and ` Content-Type ` of the individual ` multipart/form-data `
147+ part like so:
148+
149+ ``` python
150+ invoice_pdf = client.invoices.create_invoice_attachment(
151+ invoice_id = " inv:0-ChA4-3sU9GPd-uOC3HgvFjMWEL4N" ,
152+ image_file = (
153+ os.path.basename(pdf_filepath), # The filename to include in the `multipart/form-data` part.
154+ open (pdf_filepath, " rb" ), # The file stream, read as binary data.
155+ " application/pdf" # The Content-Type for this particular file.
156+ ),
157+ request = {
158+ " idempotency_key" : str (uuid.uuid4()),
159+ " description" : f " Invoice- { pdf_filepath} " ,
160+ }
161+ )
162+ ```
163+
143164## Exception Handling
144165
145166When the API returns a non-success status code (4xx or 5xx response), a subclass of
You can’t perform that action at this time.
0 commit comments