英文:
Is there an easy way to buffer io.ReaderAt and io.WriterAt?
问题
我正在为工作中的一个项目实现一个自定义的SFTP服务器,它将使用与AWS兼容的系统作为后端。根据我所看到的,我认为我应该使用sftp.Handlers接口来实现s3.Uploader和s3.Downloader或s3.PutObject和s3.GetObject。
我以前使用过io.PipeReader和io.PipeWriter将io.Writer连接到io.Reader,但在这种情况下,我需要做类似以下的操作:
- Get: io.ReaderAt <- ??? <- io.Reader
- Put: io.WriterAt -> ??? -> io.Reader
我猜想在这两种情况下,"???"将是不同的,但它们似乎都是一种类型的管道,我们将数据保留直到另一端可用。是否存在这样的机制,还是我需要自己实现它?对于实现它,有什么建议吗?
英文:
I'm implementing a custom sftp server for a project at work that will use an AWS compatible system as the backend. Based on what I am seeing, I'm thinking I should implement the sftp.Handlers interface using the s3.Uploader and s3.Downloader or s3.PutObject and s3.GetObject.
I've used io.PipeReader and io.PipeWriter before to pipe an io.Writer to an io.Reader but in this case, I need to do something like:
- Get: io.ReaderAt <- ??? <- io.Reader
- Put: io.WriterAt -> ??? -> io.Reader
I'm guessing ??? will be different in both cases but they both seem like they'd be a type of pipe where we hold data until it's available for the other end. Does something like this exist or do I need to implement it myself? Any suggestions on implementing it?
答案1
得分: 2
我个人正在使用https://github.com/avvmoto/buf-readerat,它专门用于缓冲ReadAt。为我节省了很多麻烦。
英文:
I'm personally making use of https://github.com/avvmoto/buf-readerat which specifically buffers ReadAt. Saved me a lot of pain.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论