예제 #1
0
    def rapid_upload_file(
        self,
        slice_md5: str,
        content_md5: str,
        content_crc32: int,  # not needed
        io_len: int,
        remotepath: str,
        local_ctime: Optional[int] = None,
        local_mtime: Optional[int] = None,
        ondup="overwrite",
    ) -> PcsFile:
        """Rapid Upload File

        slice_md5 (32 bytes): the md5 of pre 256KB of content.
        content_md5 (32 bytes): the md5 of total content.
        content_crc32 (int): the crc32 of total content (Not Needed),
            if content_crc32 is 0, the params of the api will be ignored.
        io_len (int): the length of total content.
        remotepath (str): the absolute remote path to save the content.
        """

        info = self._baidupcs.rapid_upload_file(
            slice_md5,
            content_md5,
            content_crc32,
            io_len,
            remotepath,
            local_ctime=local_ctime,
            local_mtime=local_mtime,
            ondup=ondup,
        )
        return PcsFile.from_(info)
예제 #2
0
파일: api.py 프로젝트: kidbai/BaiduPCS-Py
 def rapid_upload_file(self,
                       localpath: str,
                       remotepath: str,
                       ondup="overwrite") -> PcsFile:
     info = self._baidupcs.rapid_upload_file(localpath,
                                             remotepath,
                                             ondup=ondup)
     return PcsFile.from_(info)
예제 #3
0
파일: api.py 프로젝트: kidbai/BaiduPCS-Py
 def combine_slices(self,
                    slice_md5s: List[str],
                    remotepath: str,
                    ondup="overwrite") -> PcsFile:
     info = self._baidupcs.combine_slices(slice_md5s,
                                          remotepath,
                                          ondup=ondup)
     return PcsFile.from_(info)
예제 #4
0
파일: api.py 프로젝트: SnowMFZ/BaiduPCS-Py
 def search(
     self, keyword: str, remotepath: str, recursive: bool = False
 ) -> List[PcsFile]:
     info = self._baidupcs.search(keyword, remotepath, recursive=recursive)
     pcs_files = []
     for file_info in info["list"]:
         pcs_files.append(PcsFile.from_(file_info))
     return pcs_files
예제 #5
0
파일: api.py 프로젝트: SnowMFZ/BaiduPCS-Py
 def upload_file(
     self,
     io: IO,
     remotepath: str,
     ondup="overwrite",
     callback: Callable[[MultipartEncoderMonitor], None] = None,
 ) -> PcsFile:
     info = self._baidupcs.upload_file(
         io, remotepath, ondup=ondup, callback=callback
     )
     return PcsFile.from_(info)
예제 #6
0
파일: api.py 프로젝트: SnowMFZ/BaiduPCS-Py
 def list(
     self,
     remotepath: str,
     desc: bool = False,
     name: bool = False,
     time: bool = False,
     size: bool = False,
 ) -> List[PcsFile]:
     info = self._baidupcs.list(
         remotepath, desc=desc, name=name, time=time, size=size
     )
     return [PcsFile.from_(v) for v in info.get("list", [])]
예제 #7
0
파일: api.py 프로젝트: SnowMFZ/BaiduPCS-Py
 def rapid_upload_file(
     self,
     slice_md5: str,
     content_md5: str,
     content_crc32: int,
     io_len: int,
     remotepath: str,
     ondup="overwrite",
 ) -> PcsFile:
     info = self._baidupcs.rapid_upload_file(
         slice_md5, content_md5, content_crc32, io_len, remotepath, ondup=ondup
     )
     return PcsFile.from_(info)
예제 #8
0
def get_list():
    remotepath = '/_pcs_.safebox/'
    info = list_sbox(remotepath, time=True)
    if info['errno'] == 0:
        print(info)
        pcs_files = [PcsFile.from_(v) for v in info.get("list", [])]
        display_files(pcs_files, remotepath)
    elif info['errno'] == -9:
        print('目录不存在')
    elif info['errno'] == 27:
        print('缺少SBOXTKN值或SBOXTKN过期')
    else:
        print(info)
예제 #9
0
 def combine_slices(
     self,
     slice_md5s: List[str],
     remotepath: str,
     local_ctime: Optional[int] = None,
     local_mtime: Optional[int] = None,
     ondup="overwrite",
 ) -> PcsFile:
     info = self._baidupcs.combine_slices(
         slice_md5s,
         remotepath,
         local_ctime=local_ctime,
         local_mtime=local_mtime,
         ondup=ondup,
     )
     return PcsFile.from_(info)
예제 #10
0
    def upload_file(
        self,
        io: IO,
        remotepath: str,
        ondup="overwrite",
        callback: Callable[[MultipartEncoderMonitor], None] = None,
    ) -> PcsFile:
        """Upload an io to `remotepath`

        ondup (str): "overwrite" or "newcopy"
        callable: the callback for monitoring uploading progress

        Warning, the api CAN NOT set local_ctime and local_mtime
        """

        info = self._baidupcs.upload_file(io,
                                          remotepath,
                                          ondup=ondup,
                                          callback=callback)
        return PcsFile.from_(info)
예제 #11
0
    def combine_slices(
        self,
        slice_md5s: List[str],
        remotepath: str,
        local_ctime: Optional[int] = None,
        local_mtime: Optional[int] = None,
        ondup="overwrite",
    ) -> PcsFile:
        """Combine uploaded slices to `remotepath`

        local_ctime (optional, int): the timestramp of the local ctime
        local_mtime (optional, int): the timestramp of the local mtime
        ondup (str): "overwrite" or "newcopy"
        """

        info = self._baidupcs.combine_slices(
            slice_md5s,
            remotepath,
            local_ctime=local_ctime,
            local_mtime=local_mtime,
            ondup=ondup,
        )
        return PcsFile.from_(info)
예제 #12
0
파일: api.py 프로젝트: kidbai/BaiduPCS-Py
 def meta(self, *remotepaths: str) -> List[PcsFile]:
     info = self._baidupcs.meta(*remotepaths)
     return [PcsFile.from_(v) for v in info.get("list", [])]
예제 #13
0
파일: api.py 프로젝트: kidbai/BaiduPCS-Py
 def makedir(self, directory: str) -> PcsFile:
     info = self._baidupcs.makedir(directory)
     return PcsFile.from_(info)