Skip to content

Argument of type 'string | ArrayBuffer | Blob | number[] | Uint8Array | Buffer | ReadableStream' is not assignable to parameter of type 'Blob | MediaSource'. #120

@nadralia

Description

@nadralia

I keep getting this typescript issue here below on this line const url = URL.createObjectURL(blob);

Argument of type 'string | ArrayBuffer | Blob | number[] | Uint8Array | Buffer | ReadableStream' is not assignable to parameter of type 'Blob | MediaSource'.
Type 'string' is not assignable to type 'Blob | MediaSource'.ts(2345)
const blob: string | Blob | number[] | Uint8Array | ArrayBuffer | Buffer | ReadableStream

    const convertToShapefileAndDownload = async (geoJson) => {
        try {
            if (!geoJson || typeof geoJson !== 'object') {
                throw new Error('Invalid GeoJSON data');
            }

            const options: any = { 
                folder: 'plots',
                types: {
                    point: 'points',
                    polygon: 'polygons',
                    polyline: 'lines',
                },
                compression: 'STORE' as any,
                outputType: 'blob',
            };

            const blob = await shpwrite.zip(geoJson, options);
            const url = URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = url;
            link.download = 'plots_shapefile.zip';
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
            URL.revokeObjectURL(url);
        } catch (error) {
            //handleNotification(error, 'error');
            console.error('Error converting to Shapefile:', error.message);
        }
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions