dlgs icon indicating copy to clipboard operation
dlgs copied to clipboard

FileMulti can only choose 10 files cant more

Open crash-override404 opened this issue 5 years ago • 4 comments

So i'm using https://github.com/go-flutter-desktop/go-flutter and use plugin https://github.com/miguelpruivo/flutter_file_picker, but when i pick multi file there is only show 10 files not more. And i check the package file_picker use and then when i see it i found this repo, and i try to use it independent but only show when i choose 10 files.

This is my code

package main

import (
	"log"
	"strings"

	"github.com/gen2brain/dlgs"
	"github.com/pkg/errors"
)


func main() {
	filter, err := fileFilter("ANY")
	if err != nil {
		log.Println("Failed to get filter", err)
		return
	}
	filePaths, _, err := dlgs.FileMulti("Select one or more files", filter)
	if err != nil {
		log.Println("Failed to open dialog picker")
		return
	}

	// type []string is not supported by StandardMessageCodec
	sliceFilePaths := make([]interface{}, len(filePaths))
	for i, file := range filePaths {
		sliceFilePaths[i] = file
	}
	log.Println(sliceFilePaths)
}

func fileFilter(method string) (string, error) {
	switch method {
	case "ANY":
		return "*", nil
	case "IMAGE":
		return "Images (*.jpeg,*.png,*.gif)\x00*.jpg;*.jpeg;*.png;*.gif\x00All Files (*.*)\x00*.*\x00\x00", nil
	case "AUDIO":
		return "Audios (*.mp3)\x00*.mp3\x00All Files (*.*)\x00*.*\x00\x00", nil
	case "VIDEO":
		return "Videos (*.webm,*.wmv,*.mpeg,*.mkv,*.mp4,*.avi,*.mov,*.flv)\x00*.webm;*.wmv;*.mpeg;*.mkv;*mp4;*.avi;*.mov;*.flv\x00All Files (*.*)\x00*.*\x00\x00", nil
	default:
		if strings.HasPrefix(method, "__CUSTOM_") {
			resolveType := strings.Split(method, "__CUSTOM_")
			return "Files (*." + resolveType[1] + ")\x00*." + resolveType[1] + "\x00All Files (*.*)\x00*.*\x00\x00", nil
		}
		return "", errors.New("unknown method")
	}
}

func fileDialog(title string, filter string) (string, error) {
	filePath, _, err := dlgs.File(title, filter, false)
	if err != nil {
		return "", errors.Wrap(err, "failed to open dialog picker")
	}
	return filePath, nil
}

crash-override404 avatar Jan 31 '20 07:01 crash-override404

I've been fix this issue by change manually the maxPath, but is there a way to not limit the max file?

crash-override404 avatar Jan 31 '20 07:01 crash-override404

That is just getOpenFileName from win32 API https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamew . In docs says it should be at least that size, so it is. You can send PR with changed maximum.

gen2brain avatar Feb 03 '20 16:02 gen2brain

Yeah you should give function for change the maximum length

crash-override404 avatar Feb 06 '20 05:02 crash-override404

In github.com/ncruces/zenity I use 32768 which is the maximum path size on NTFS.

Actually for multiple file selections I do 32768+1024*256 which allows a 32768-character folder path, followed by 1024 256-character filenames.

ncruces avatar Mar 30 '21 01:03 ncruces