Open resucutie opened 8 months ago
I'm not sure what you trying to accomplish. Copying file URls to clipboard will work differently on each operating system. Also depends on whether the application that you paste into even supports file URLs in the clipboard. On Android this will likely not work at all because of sandboxing.
What exactly is a "weird file"?
Sorry for the late response! basically i am trying to copy a file to the clipboard that I don't know its extension.
Either way, do you recommend any way to copy to clipboard a local file? I was trying a few solutions but they don't seem to work well, or fail on the weird Discord bug that I showed
Also forgot to inform what did I meant with weird file. When I tried to copy with whatever implementation I had and pasted it on an application like Discord, it would give the result that I've shown on image. I also tried to paste on the a GitHub issue writer (where you write the issue, idk if it even has a name) and the file was able to load. I was confused in some way
Also forgot to inform what did I meant with weird file. When I tried to copy with whatever implementation I had and pasted it on an application like Discord, it would give the result that I've shown on image. I also tried to paste on the a GitHub issue writer (where you write the issue, idk if it even has a name) and the file was able to load. I was confused in some way
On a second thought, this may have been caused due to sandboxing on Flatpak applications, since on Linux systems it copies as a file path. I may gonna test it out better using Formats.jpeg
or something. Unless you have a different solution
After checking out, apparently using Formats.jpeg was working on Android, but not on Linux. Do you have any idea why?
final item = DataWriterItem();
item.add(Formats.jpeg(await File(image.path).readAsBytes()));
await SystemClipboard.instance?.write([item]);
After doing some testing, apparently it only copies .png files on Linux. Is that intentional or a Linux fluke?
You can write anything in the clipboard - important thing is what the target application supports. If application that you're pasting into only supports PNG then only PNG will work.
forgot to reply but it seems to copy images now. imma test videos whenver i implement on my application. as of now i'll close this
i've found out that copying videos does not work, at least on linux. doing item.add(Formats.mp4(await File(image.path).readAsBytes()))
does not result in a video copied.
for GIFs, it just yeets a static image
the same behavior can be observed for dragging and dropping
I've been trying to use super_clipboard to copy unspecific files, but I couldn't get it working
On Linux, and presumably on desktop, it just gives a weird file, although uploading on GitHub actually outputs a valid file
On Android, it crashes and outputs this: