# -*- encoding: utf-8 -*- # Created on 2019/5/7 16:14 # Project: ztb_yunnan_ynggzy import os import oss2 import requests from fuclib import ezfuc from yscredit_tools import Logger requests.packages.urllib3.disable_warnings() Logger.config(level="info", processname="ztb_lntb_day") class oss(object): def __init__(self): self.session = requests.Session() self.session.verify = False self.headers = {"User-Agent": ezfuc.random_ua()} self.logger = Logger self.base_dir = os.path.abspath('.') self.url = "https://www.lntb.gov.cn/mhback/api/cTenderProjectNode/checkList" # self.bucket = oss2.Bucket(oss2.Auth("LTAI4GEzWAksbxEaZe8cGSPj", "MB9W9yi8rI1RS9Z2O9uWaAOJZdUSAv"), "http://oss-cn-beijing-internal.aliyuncs.com", "ys-ztb") # 上线用 self.bucket = oss2.Bucket(oss2.Auth("LTAI4GEzWAksbxEaZe8cGSPj", "MB9W9yi8rI1RS9Z2O9uWaAOJZdUSAv"), "http://oss-cn-beijing.aliyuncs.com", "ys-ztb") # 测试用 def object_exists(self, file_name): # 查询文件是否存在 exist = self.bucket.object_exists(file_name) if exist: print('object exist') else: print('object not exist') def upload_file(self, path, oss_id): # 上传文件 status = self.bucket.put_object('{}'.format(oss_id), path) Logger.info(status.status) if __name__ == '__main__': ys = oss() ys.object_exists("8c27af52fbf69adecf49bed007dd99f3(0).pdf")
标签:语句,__,常用,oss,object,oss2,import,self From: https://www.cnblogs.com/yoyo1216/p/16895689.html