Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

FileMulti can only choose 10 files cant more #12

Open
crash-override404 opened this issue Jan 31, 2020 · 4 comments
Open

FileMulti can only choose 10 files cant more #12

crash-override404 opened this issue Jan 31, 2020 · 4 comments

Comments

@crash-override404
Copy link

crash-override404 commented Jan 31, 2020

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
Copy link
Author

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

@gen2brain
Copy link
Owner

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.

@crash-override404
Copy link
Author

Yeah you should give function for change the maximum length

@ncruces
Copy link

ncruces commented Mar 30, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants