Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview an existing image with base64 string or byte[] #71

Open
MatiasBordoy opened this issue Jun 29, 2024 · 1 comment
Open

Preview an existing image with base64 string or byte[] #71

MatiasBordoy opened this issue Jun 29, 2024 · 1 comment

Comments

@MatiasBordoy
Copy link

MatiasBordoy commented Jun 29, 2024

Hello i'm having trouble with the preview image in file pond when it has to show an existing file that comes from the server and it's in byte[] or base64String format.

im not using an API, i already have the file as an array[] in a c# blazor app that calls the .js file with interop and passes the file as a paraemter to the function.

And i can't initialize the image properly it's shown like with an "empty" image inside the . I don't find anything in the docs as an example of that.

I tried this with no luck:

try {
FilePond.registerPlugin(
FilePondPluginFileValidateSize,
FilePondPluginFileValidateType,
FilePondPluginImageExifOrientation,
FilePondPluginImagePreview,
FilePondPluginImageCrop,
FilePondPluginImageResize,
FilePondPluginImageTransform,
);

let files = [];
if (base64Image != '') {
    files = [
        {
            source: `data:${imageMimeType};base64,${base64Image}`,
            options: {
                type: 'local'
            },
        }
    ];
}

const filePond = FilePond.create(
    document.getElementById(elementId),
    {
        element: null,
        allowFileSizeValidation: allowFileSizeValidation,
        minFileSize: minFileSize,
        maxFileSize: maxFileSize,
        maxTotalFileSize: maxTotalfileSize,
        imagePreviewHeight: imagePreviewHeight,
        imageCropAspectRatio: '1:1',
        imageResizeTargetWidth: imageResizeTargetWidth,
        imageResizeTargetHeight: imageResizeTargetHeight,
        stylePanelLayout: 'compact circle',
        styleLoadIndicatorPosition: 'center bottom',
        styleProgressIndicatorPosition: 'right bottom',
        styleButtonRemoveItemPosition: 'left bottom',
        styleButtonProcessItemPosition: 'right bottom',
        files: files,
    }
);
@rikschennink
Copy link
Collaborator

Type 'local' means that the file is located on the server, FilePond will try to load it from there.

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

No branches or pull requests

2 participants