(filedata, analyst, source, reference, use_hdr_src,
                        import_now=False)
Take the given file data and save each contained STIX document in the DB.
    If the file is a ZIP, extract and save each STIX document.

    :param filedata: The uploaded filedata
    :type filedata: :class:`django.core.files.uploadedfile.InMemoryUploadedFile`
    :param analyst: Userid of the analyst who uploaded the data
    :type analyst: string
    :param source: The analyst provided source name of the data
    :type source: string
    :param reference: A reference to the source of the data
    :type reference: string
    :param use_hdr_src: If True, try to use the STIX Header Information Source
                         instead of the value in "source" parameter
    :type use_hdr_src: boolean
    :param import_now: If True, import all STIX data into CRITs
    :type import_now: boolean
    :returns: dictionary
Take the given file data and save each contained STIX document in the DB.
    If the file is a ZIP, extract and save each STIX document.
Take the given file data and save each contained STIX document in the DB . If the file is a ZIP extract and save each STIX document .
def process_stix_upload(filedata, analyst, source, reference, use_hdr_src,
                        import_now=False):
    """
    Take the given file data and save each contained STIX document in the DB.
    If the file is a ZIP, extract and save each STIX document.

    :param filedata: The uploaded filedata
    :type filedata: :class:`django.core.files.uploadedfile.InMemoryUploadedFile`
    :param analyst: Userid of the analyst who uploaded the data
    :type analyst: string
    :param source: The analyst provided source name of the data
    :type source: string
    :param reference: A reference to the source of the data
    :type reference: string
    :param use_hdr_src: If True, try to use the STIX Header Information Source
                         instead of the value in "source" parameter
    :type use_hdr_src: boolean
    :param import_now: If True, import all STIX data into CRITs
    :type import_now: boolean
    :returns: dictionary
    """

    t_stamp = datetime.now(tzutc())
    t_stamp = t_stamp.replace(microsecond=t_stamp.microsecond / 1000 * 1000)
    top_name = filedata.name

    if import_now:
        ret = {
                'successes': 0,
                'failures': [],
                'Certificate': [],
                'Domain': [],
                'Email': [],
                'Event': [],
                'Indicator': [],
                'IP': [],
                'PCAP': [],
                'RawData': [],
                'Sample': [],
               }

    if zipfile.is_zipfile(filedata):
        with zipfile.ZipFile(filedata, 'r') as z:
            for zinfo in z.infolist():
                result = process_stix_doc(z.open(zinfo), zinfo.filename,
                                       t_stamp, source, reference, use_hdr_src,
                                       analyst, import_now, top_name)
                if result and result['status']:
                    for k in ret:
                        if k == 'successes':
                            ret[k] += result[k]
                        else:
                            ret[k].extend(result[k])
    else:
        filedata.seek(0)
        ret = process_stix_doc(filedata, top_name, t_stamp, source,
                               reference, use_hdr_src, analyst, import_now)

    if import_now:
        return ret
    else:
        poll_id = t_stamp.replace(tzinfo=None)-datetime(1970,1,1)
        poll_id = '%.3f' % poll_id.total_seconds()
        return generate_import_preview(poll_id, analyst)
def process_stix_upload ( filedata , analyst , source , reference , use_hdr_src , import_now = False ) : t_stamp = datetime . now ( tzutc ( ) ) t_stamp = t_stamp . replace ( microsecond = t_stamp . microsecond / 1000 * 1000 ) top_name = filedata . name if import_now : ret = { 'successes' : 0 , 'failures' : [ ] , 'Certificate' : [ ] , 'Domain' : [ ] , 'Email' : [ ] , 'Event' : [ ] , 'Indicator' : [ ] , 'IP' : [ ] , 'PCAP' : [ ] , 'RawData' : [ ] , 'Sample' : [ ] , } if zipfile . is_zipfile ( filedata ) : with zipfile . ZipFile ( filedata , 'r' ) as z : for zinfo in z . infolist ( ) : result = process_stix_doc ( z . open ( zinfo ) , zinfo . filename , t_stamp , source , reference , use_hdr_src , analyst , import_now , top_name ) if result and result [ 'status' ] : for k in ret : if k == 'successes' : ret [ k ] += result [ k ] else : ret [ k ] . extend ( result [ k ] ) else : filedata . seek ( 0 ) ret = process_stix_doc ( filedata , top_name , t_stamp , source , reference , use_hdr_src , analyst , import_now ) if import_now : return ret else : poll_id = t_stamp . replace ( tzinfo = None ) - datetime ( 1970 , 1 , 1 ) poll_id = '%.3f' % poll_id . total_seconds ( ) return generate_import_preview ( poll_id , analyst )