Skip to content

Problem with sharp library on Android (arm64) when using WebDAV #260

@neumann-d

Description

@neumann-d

Got @internxt/cli running on Android using the Termux app. The problem I had when starting webdav was the import of the sharp library which is imported by the ./services/thumbnail.service.ts.

When starting the webdav server via internxt webdav enable only the status errored was shown after some seconds when calling internxt webdav status. When digging deeper and started webdav via node dist/webdav/index.js directly, the error Could not load the "sharp" module using the android-arm64 runtime including stack trace occured.

As a workaround I "deactivated" the thumbnail feature by commenting out the following 4 lines (see // COMMENTED OUT in the code) in dist/services/thumbnail.service.ts:

import { Readable } from 'node:stream';
import { DriveFileService } from './drive/drive-file.service';
import { StorageTypes } from '@internxt/sdk/dist/drive';
import { NetworkFacade } from './network/network-facade.service';
import { isImageThumbnailable, ThumbnailConfig } from '../utils/thumbnail.utils';
// import sharp from 'sharp'; // COMMENTED OUT

export class ThumbnailService {
  public static readonly instance: ThumbnailService = new ThumbnailService();

  public uploadThumbnail = async (
    fileContent: Buffer,
    fileType: string,
    userBucket: string,
    file_id: number,
    networkFacade: NetworkFacade,
  ): Promise<StorageTypes.Thumbnail | undefined> => {
    let thumbnailBuffer: Buffer | undefined;
    // if (isImageThumbnailable(fileType)) {  // COMMENTED OUT
    // thumbnailBuffer = await this.getThumbnailFromImageBuffer(fileContent); // COMMENTED OUT
    // }  // COMMENTED OUT
    if (thumbnailBuffer) {
   ...

With this workaround webdav now also works on Android. I read that nextjs for example replaced the sharp library by a wasm variant: https://github.com/vercel/next.js/pull/22253/files#diff-db50b6377121431a62bd3d0353283eef8e1c28782fe3a30ba685d8130dd4b044

Maybe this could be a solution for the future?

Last but not least, here are my instructions for installing @internxt/cli in the Termux app on Android:

$ pkg update
$ pkg upgrade
$ pkg install binutils
$ pkg install python
$ pkg install nodejs-lts
$ mkdir -p ~/.gyp
$ nano ~/.gyp/include.gypi
# Add the following and save with ctrl+s and exit nano with ctrl+x
{
    'variables': {
        'android_ndk_path': ''
    }
}
$ python -m pip install setuptools
$ npm i -g @internxt/cli

For running syncs via webdav I can recommend the FolderSync app. Of course, if the Internxt Android app would provide a file/folder synchronization feature in the future, this would be the preferred and much more comfortable solution! ;)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions