#NEWLINE# def add_file_to_resource( self , edit_media_iri , payload , filename , mimetype = None , packaging = None , md5sum = None , on_behalf_of = None , in_progress = False , metadata_relevant = False ) : #NEWLINE# #INDENT# '\nAdding Files to the Media Resource\n\nFrom the spec, paraphrased:\n    \n    "This feature is for use when clients wish to send individual files to the server and to receive back the IRI for the created resource. [Adding new items to the deposit container] will not give back the location of the deposited resources, so in cases where the server does not provide the (optional) Deposit Receipt, it is not possible for the client to ascertain the location of the file actually deposited - the Location header in that operation is the Edit-IRI. By POSTing to the EM-IRI, the Location header will return the IRI of the deposited file itself, rather than that of the container.\n\nAs the EM-IRI represents the Media Resource itself, rather than the Container, this operation will not formally support metadata handling, and therefore also offers no explicit support for packaging either since packages may be both content and metadata. Nonetheless, for files which may contain extractable metadata, there is a Metadata-Relevant header which can be defined to indicate whether the deposit can be used to augment the metadata of the container."\n\n#BETASWORD2URL\nSee http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/trunk/SWORDProfile.html?revision=HEAD#protocoloperations_addingcontent_mediaresource\n\n\nSet the following parameters in addition to the basic parameters:\n\n    `edit_media_iri` - The Edit-Media-IRI\n    \n    `payload`   - the payload to send. Can be either a bytestring or a File-like object that supports `payload.read()`\n    `mimetype`  - MIMEType of the payload\n    `filename`  - filename. Most SWORD2 uploads have this as being mandatory.\n    `packaging` - the SWORD2 packaging type of the payload. \n                    eg packaging = \'http://purl.org/net/sword/package/Binary\'\n        \nResponse:\n    \nA `sword2.Deposit_Receipt` object containing the deposit receipt data. If the response was blank or \nnot a Deposit Response, then only a few attributes will be populated:\n            \n    `code` -- HTTP code of the response\n    `response_headers`  -- `dict` of the reponse headers\n    `content`  --  (Optional) in case the response body is not empty but the response is not a Deposit Receipt\n        \nIf exception-throwing is turned off (`error_response_raises_exceptions = False` or `self.raise_except = False`)\nthen the response will be a `sword2.Error_Document`, but will still have the aforementioned attributes set, (code,\nresponse_headers, etc)\n\n        ' #NEWLINE# conn_l . info ( ( 'Appending file to a deposit via Edit-Media-IRI %s' % edit_media_iri ) ) #NEWLINE# return self . _make_request ( target_iri = edit_media_iri , payload = payload , mimetype = mimetype , packaging = packaging , filename = filename , on_behalf_of = on_behalf_of , in_progress = in_progress , method = 'POST' , metadata_relevant = metadata_relevant , request_type = 'EM_IRI POST (APPEND)' , md5sum = md5sum )