Giter VIP home page Giter VIP logo

upload-wizard's People

Contributors

gio-shara-code avatar github-actions[bot] avatar marvin-kolja avatar

Stargazers

 avatar  avatar

Watchers

 avatar

upload-wizard's Issues

Confirm Upload may fail due different s3 bucket configuration

Problem description

When configuring the S3Provider with an alternate resource bucket config, the confirmUpload method of the UploadWizard server class may fail. This is caused by calling the getData method of the S3Provider and throwing an error if the method returns a status of "FileNotFound". This status is returned under the following conditions. The option optimisticFileDataResponse must be set to false (always makes a network request to validate data existence), and if the resource bucket is configured differently from the upload bucket. Once the upload is finished, the getData method does not check if the file is in the upload bucket, only if it’s in the resource bucket, resulting in a mismatch of information.

Possible solutions

  1. Rewrite the getData method of the S3Provider to check if the file is in the upload bucket returning the status "UPLOADED". This will not throw an error up the chain.

    Problems with this approach:

    The problem with this approach is that when optimisticFileDataResponse is set to true, there would be no check for the file's existence. On the other hand, we could implement a check for the upload bucket even when it is returning the file data optimistically. However, that would defeat the idea of an optimisticFileDataResponse.

    Other considerations:

    1. Maybe it does make sense to remove the optimisticFileDataResponse after all. This would resolve this problem easier and guarantee that the returned information is correct.

    2. Another idea could be to always check if a file exists in the upload bucket. When optimisticFileDataResponse is true, then check every time. When it's false, only check when files have not been found in the resource bucket. Yes, this would kind of defeat the purpose of the optimisticFileDataResponse; however, it would provide the safety needed.

  2. Add another method to the provider interface that primarily checks if a file has been uploaded.

    Problems with this approach:

    This would nicely separate the code of the file data request and check if the file has been uploaded. However, some other providers (that do not exist at this point) would not need that function. Cloudflare Images, for example, has one request to get information about the uploaded image. This can already be handled in the existing getData method.

Build fails on first execution

For some reason, the build fails when doing it the first time.

I discovered this issue first here: https://github.com/gio-shara-code/upload-wizard/actions/runs/5489815772/jobs/10004448611.

Then I tried to execute pnpm build on my local machine with a clean install and removed all dist dirs. This was the output:

@server/core:build: src/types/upload-wizard.types.ts(2,40): error TS2307: Cannot find module '@providers/interface' or its corresponding type declarations.
@server/core:build: src/types/upload-wizard.types.ts(3,32): error TS2307: Cannot find module '@adapters/interface' or its corresponding type declarations.
@server/core:build: src/upload-wizard.ts(1,45): error TS2307: Cannot find module '@providers/interface' or its corresponding type declarations.
@server/core:build: src/upload-wizard.ts(2,37): error TS2307: Cannot find module '@adapters/interface' or its corresponding type declarations.
@server/core:build:  ELIFECYCLE  Command failed with exit code 2.
@server/core:build: Error: command finished with error: command (packages/server/core) pnpm run build exited (1)
@gio-shara/example-package:build:  ELIFECYCLE  Command failed.
@gio-shara/example-package:build:  WARN   Local package.json exists, but node_modules missing, did you mean to install?
@providers/s3:build:  ELIFECYCLE  Command failed.
command (packages/server/core) pnpm run build exited (1)

 Tasks:    3 successful, 4 total
Cached:    0 cached, 4 total
  Time:    1.466s 

 ELIFECYCLE  Command failed with exit code 1.

The next pnpm build execution succeeded:

 Tasks:    6 successful, 6 total
Cached:    3 cached, 6 total
  Time:    1.651s 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.