"""
author:张鑫
date:2021/10/14 17:14
"""
import paramiko
ip = "140.210.4.73" # 服务器ip
port = 22 # 端口号
username = "zs_caoye" # 用户名
password = "zs_caoye#@!s" # 密码
# 本地资源位置
file_name = ''
local = fr'C:\Users\li9\Desktop\facebook\网红\{file_name}'
# 服务器位置
remote = f'/home/wwwroot/tw_ipadsvn/resource/assets/upload/img/cjimg/{file_name}'
def uploadfiletoserver(local, remote):
# 创建SSH对象
ssh = paramiko.SSHClient()
# 允许连接不在know_hosts文件中的主机
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, port, username, password)
sftp = ssh.open_sftp()
sftp.put(local, remote)
print('上传成功')
# 视频链接
# 调用接口
video_link = f'http://twipad.hnxinxiudata.top/resource/assets/upload/img/cjimg/{file_name}'
print('视频接口', video_link)