You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

http_uploading_iterator.go 818 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package iterator
  2. import (
  3. "mime/multipart"
  4. )
  5. type HTTPUploadingIterator struct {
  6. files []*multipart.FileHeader
  7. currentIndex int
  8. }
  9. func NewHTTPObjectIterator(files []*multipart.FileHeader) *HTTPUploadingIterator {
  10. return &HTTPUploadingIterator{
  11. files: files,
  12. }
  13. }
  14. func (i *HTTPUploadingIterator) MoveNext() (*IterUploadingObject, error) {
  15. if i.currentIndex >= len(i.files) {
  16. return nil, ErrNoMoreItem
  17. }
  18. item, err := i.doMove()
  19. i.currentIndex++
  20. return item, err
  21. }
  22. func (i *HTTPUploadingIterator) doMove() (*IterUploadingObject, error) {
  23. fileInfo := i.files[i.currentIndex]
  24. file, err := fileInfo.Open()
  25. if err != nil {
  26. return nil, err
  27. }
  28. return &IterUploadingObject{
  29. Path: fileInfo.Filename,
  30. Size: fileInfo.Size,
  31. File: file,
  32. }, nil
  33. }
  34. func (i *HTTPUploadingIterator) Close() {
  35. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。