def normal(_, auth, __, post): content_type = Format.get(post, 'content_type') current_folder = Format.get(post, 'current_folder', 'folder/') file_name = Format.get(post, 'file_name', str(time.time() * 1000)) intranet = bool(Format.get(post, 'intranet', False)) return cs.Upload(auth['act'], auth['app']).normal(content_type, current_folder, file_name, intranet)
def folder(_, auth, __, post): current_folder = Format.get(post, 'current_folder', 'folder/') folder_name = Format.get(post, 'folder_name') for param in (current_folder, folder_name): if param is None: return CommonErr.PARAM_MISS return cs.Upload(auth['act'], auth['app']).folder(current_folder, folder_name)
def folder_file(_, auth, __, post): current_folder = Format.get(post, 'current_folder', 'folder/') file_name = Format.get(post, 'file_name', str(time.time() * 1000)) folder_file = Format.get(post, 'folder_file') source_file = Format.get(post, 'source_file') if folder_file is None or source_file is None: return CommonErr.PARAM_MISS return cs.Upload(auth['act'], auth['app']).folder_file(current_folder, file_name, folder_file, source_file)
def normal(_, auth, __, post): content_type = Format.get(post, 'content_type') expires = int(Format.get(post, 'expires', 60)) folder_file = Format.get(post, 'folder_file') intranet = bool(Format.get(post, 'intranet', False)) source_file = Format.get(post, 'source_file') if folder_file is None or source_file is None: return CommonErr.PARAM_MISS return cs.Download(auth['act'], auth['app']).normal(content_type, expires, folder_file, intranet, source_file)
def __init__(self, appid, suffix, source=None): """ :param str appid: Application id :param str suffix: Eg: folder/${FolderId}/.../t=${CreateTime}&n=${FileName}&i=${FileId} :param Source source: Source file """ self.source = source self.suffix = suffix self.__prefix = default.PREFIX.format(appid) self.key = '{0}{1}'.format(self.__prefix, suffix) if not isinstance(source, Source): self.source = Source(appid, file_id=Format.parse_qs( suffix.split('/')[-1])['i'])
def __init__(self, appid, suffix): """ :param str appid: Application id :param str suffix: Eg: folder/.../,t=${CreateTime}&n=${FolderName}&i=${FolderId} """ self.suffix = suffix part = suffix.split(default.RESERVE_CHAR) self.__prefix = default.PREFIX.format(appid) self.key = '{0}{1}'.format(self.__prefix, self.suffix) if len(part) == 1: self.directory = 'folder/' else: self.directory = '{0}{1}/'.format(part[0], Format.parse_qs(part[1])['i'])
def create(appid, file_name, folder, source): """ :param str appid: Application id :param str file_name: Filename :param Folder folder: File folder :param Source source: Source file :return: """ folder_file_qs = Format.query_string([ ('t', Time.unix_str()), ('n', file_name), ('i', source.file_id), ]) suffix = '{0}{1}'.format(folder.directory, folder_file_qs) return FolderFile(appid, suffix, source)
def create(appid, folder_name, folder): """ :param str appid: Application id :param str folder_name: Folder name :param Folder folder: File folder :return: """ folder_id = Random.string(default.FOLDER_ID_LEN) folder_qs = Format.query_string([ ('t', Time.unix_str()), ('n', folder_name), ('i', folder_id), ]) return Folder( appid, '{0}{1}{2}'.format(folder.directory, default.RESERVE_CHAR, folder_qs))