Uploading file on S3 does not working on Railway
davispc10
HOBBYOP

a year ago

In my bun project, I am creating a s3 service to upload blob files. It's working on local, but this not working on railway.

I'm using the libs @aws-sdk/lib-storage.

if (!key) key = this.generateKey();
    if (typeof file === 'string') {
      file = Buffer.from(file, 'base64');
    }
    if (file instanceof Blob) {
      file = await file.bytes();
    }
    const params = {
      Bucket: env.S3_BUCKET,
      Key: key,
      Body: file,
      ContentType: contentType,
      ContentDisposition: 'inline',
    };

    const s3 = new Upload({
      client: this.s3,
      params,
      queueSize: 4,
      partSize: 1024 * 1024 * 5,
      leavePartsOnError: false,
    });
    try {
      await s3.done();
    } catch (error) {
      console.log('error');
      console.log(error);
    }

The process freeze in s3.done().

0 Replies

Loading...