Exemple #1
0
    def chunk(self, iden, byts):
        '''
        Save a chunk of a blob allocated with alloc().
        '''
        info = self.inprog.get(iden)

        if info is None:
            raise s_common.NoSuchIden(iden)

        cur = info.get('cur')
        self.heap.writeoff(cur, byts)

        info['cur'] += len(byts)

        hset = info.get('hashset')
        hset.update(byts)

        # if the upload is complete, fire the add event
        if info['cur'] == info['maxoff']:

            self.inprog.pop(iden, None)

            off = info.get('off')
            iden, props = hset.guid()

            return self.core.formTufoByProp('axon:blob', iden, off=off, **props)
Exemple #2
0
    def chunk(self, iden, byts):
        info = self.saves.get(iden)
        if info is None:
            s_common.NoSuchIden(iden)

        axon = info.get('axon')
        retn = axon.chunk(iden, byts)
        if retn is not None:
            self.saves.pop(iden, None)

        return retn
Exemple #3
0
    def chunk(self, iden, byts):
        '''
        Save a chunk of a blob allocated with alloc().

        Args:
            iden (str): The file upload guid started with alloc().
            byts (bytes): Bytes to write to the blob.

        Returns:
            (bool): True for the last chunk.

        Raises:
            NoSuchIden: If the iden is not in progress.
            AxonBadChunk: If a chunk would write past the allocation size.
        '''
        upld = self.inprog.get(iden)
        if upld is None:
            raise s_common.NoSuchIden(iden)

        return upld.write(byts)
Exemple #4
0
    def chunk(self, iden, byts):
        '''
        Save a chunk of a blob allocated with alloc().

        Args:
            iden (str): Iden to save bytes too
            byts (bytes): Bytes to write to the blob.

        Returns:
            ((str, dict)): axon:blob node if the upload is complete; otherwise None.

        Raises:
            NoSuchIden: If the iden is not in progress.
        '''
        info = self.inprog.get(iden)

        if info is None:
            raise s_common.NoSuchIden(iden)

        cur = info.get('cur')
        self.heap.writeoff(cur, byts)

        info['cur'] += len(byts)

        hset = info.get('hashset')
        hset.update(byts)

        # if the upload is complete, fire the add event
        if info['cur'] == info['maxoff']:

            self.inprog.pop(iden, None)

            off = info.get('off')
            iden, props = hset.guid()

            return self.core.formTufoByProp('axon:blob',
                                            iden,
                                            off=off,
                                            **props)