python文件存储服务器_使用pysmb将文件存储到本地服务器

我正在写一个脚本来同步本地synology nas上的共享文件夹。我能够连接,读取文件,并删除没有问题,但在复制(存储文件)结巴。在

pysmb的文件是这样的storeFile(service_name, path, file_obj, timeout=30)

Store the contents of the file_obj at path on the service_name. If

the file already exists on the remote server, it will be truncated

and overwritten.

Parameters:

service_name (string/unicode) – the name of the shared folder for the

path

path (string/unicode) – Path of the file on the remote server. If the

file at path does not exist, it will be created. Otherwise, it will

be overwritten. If the path refers to a folder or the file cannot be

opened for writing, an OperationFailure will be raised.

file_obj – A file-like object that has a read method. Data will read

continuously from file_obj until EOF.

Returns:

Number of bytes uploaded

我好像无法传递正确类型的文件obj。我收到的主要错误是

^{pr2}$

这是我的尝试with open(start_path + f, 'rb', buffering=0) as file_obj:

conn.storeFile(server_path, '/', file_obj)

file_obj.closed

我也试过用拜特西奥. 从我的结论是,我必须传递一个字节对象而不打开它,因为它试图这样做,但我怎么能从驱动器得到字节文件?有什么想法吗?在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值