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

S3 upload function does not return files keys #3

Closed
Twathik opened this issue Feb 20, 2022 · 3 comments
Closed

S3 upload function does not return files keys #3

Twathik opened this issue Feb 20, 2022 · 3 comments

Comments

@Twathik
Copy link

Twathik commented Feb 20, 2022

wunderctl version : 0.60.2
@wundergraph/sdk: "^0.75",
OS: mac os 11 big sir
node v : 17

I have removed the fileConfig method check so I can try the S3 upload function (otherwise the function does not work due to an error in the generated client already reported in https://github.com/wundergraph/nextjs-typescript-postgresql-graphql-realtime-chat/issues/1#issue-1133968792)

I have managed to upload the file to local minio instance but the response returns an empty object

{
    "status": "ok",
    "body": {}
}

the files keys are not returned from the upload function

I have used a simple implementation

const {
    client: { uploadFiles,  },
  } = useWunderGraph();
  const [files, setFiles] = useState<FileList>();
  const [data, setData] = useState<UploadResponse[]>([]);
  const onFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    if (e.target.files) setFiles(e.target.files);
  };


  const onSubmit = async (e: React.FormEvent<Element>): Promise<void> => {
    e.preventDefault();
    const formData = new FormData();
    if (!files) return;
    for (const key in Object.keys(files)) {
      formData.append('files', files[key]);
    }
    formData.append('files', files[0]);
    const result = await uploadFiles({ provider: S3Provider.minio, formData });

    if (result.status === 'ok') {
    console.log({ result: JSON.stringify(result) });
      setData(result.body);
    }
  };

I have checked the minio instance and the files were successfully uploaded

@Twathik
Copy link
Author

Twathik commented Feb 23, 2022

Version 0.76 fixed the error in the generated client, but the response still don't return the uploaded files keys

@StarpTech
Copy link

Hi, @Twathik, we found it. Please retry with the latest SDK version.

@Twathik
Copy link
Author

Twathik commented Feb 26, 2022

Awesome thank you!!!

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