This is a more advanced Python code sample to show how to send a fax with a large document. This code sample is based on the Python library for InterFAX available on Github.
This sample demonstrates how to upload a large file to InterFAX using the Document component and then sending a fax to a single recipient while referencing that previously uploaded file - all you need to do in order to change it is to provide a different fax number and a different path to the files that you would like to send. You can also change the size of the chunk that you will be uploading the file with.
import os # create a new InterFAX Document document = interfax.documents.create( "test.pdf", os.stat("test.pdf").st_size ) # read the file to send with open("test.pdf", "rb") as fp: cursor = 0 while True: chunk = fp.read(500) if not chunk: break next_cursor = cursor + len(chunk) # upload each chunk document.upload(cursor, next_cursor-1, chunk) cursor = next_cursor # send the fax interfax.deliver( # a valid fax number fax_number='+11111111112', # the document URI files=[document.uri] )
You can check on the status of this fax by following this sample code.
- Please review our system limitations for number of pages allowed per fax and the total size of upload allowed.
- Please review our instructions on formatting a fax number.
- Please review our list of supported file types.
- Please review our list of web service error codes.
- Please review our enhanced security documentation on sending faxes with credit card data or with medical data.