Пример #1
0
    def set_file(self, data, location=None, temporary=False):
        """
        Save raw file data in the cache.

        :param data: The raw data of the file.
        :type data: str
        :param location: The location of the file.
        :type location: str

        :returns: The url to the uploaded file.
        :rtype: str
        """
        if location is None:
            location = "/api/v1/temp/datafile/" + helper.random_base32() + "/"

        self.__cache.set_file(location, data, temporary)

        return location
Пример #2
0
    def set_array(self, array_data, location=None, temporary=False):
        """
        Save array data in a cached HDF5 file.

        :param array_data: The raw data to store.
        :type array_data: numpy.ndarray|list
        :param location: The location of the file.
        :type location: str

        :returns: The url to the uploaded file.
        :rtype: str
        """
        if location is None:
            ident = helper.random_base32()
            location = "/api/v1/temp/datafile/" + ident + "/"
        else:
            ident = helper.id_from_location(location)

        path = self.__cache.file_cache_path(ident, temporary)
        hdfio.store_array_data(path, array_data)

        return location