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

[FR] provide file to StorageManager event callbacks #5328

Open
4 tasks done
aljasser opened this issue Jun 18, 2024 · 1 comment
Open
4 tasks done

[FR] provide file to StorageManager event callbacks #5328

aljasser opened this issue Jun 18, 2024 · 1 comment
Labels
feature-request Request a new feature Storage An issue or a feature-request for Storage Component StorageManager StorageManager related issue of feature request

Comments

@aljasser
Copy link

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Storage (Storage Manager)

How is your app built?

Create React App

What browsers are you seeing the problem on?

Chrome, Firefox, Microsoft Edge, Safari

Which region are you seeing the problem in?

No response

Please describe your bug.

The file prop is undefined in all callbacks (onFileRemove, onUploadStart, onUploadSuccess, onUploadError) except processFile. This inconsistency makes it difficult to manage file operations effectively.

What's the expected behaviour?

The file prop should be defined and available in all callbacks, not just processFile.

Help us reproduce the bug!

Include StorageManager
Implement callbacks for onFileRemove, onUploadStart, onUploadSuccess, and onUploadError
Observe that the file prop is undefined in these callbacks

Code Snippet

import React from 'react';
import { StorageManager } from "@aws-amplify/ui-react-storage";
import { v4 as uuidv4 } from 'uuid';

const ImageUploader = () => {

  const processFile = ({ file, key }) => {
    const fileExtension = file.name.split('.').pop();
    const new_key = `${uuidv4()}.${fileExtension}`;
    console.log("from processFile, file:", file);
    return { file, key: new_key };
  };

  const handleFileRemove = ({ file, key }) => {
    console.log("from onFileRemove, file:", file);
  };

  const handleUploadSuccess = ({ file, key }) => {
    console.log("from onUploadSuccess, file:", file);
  };

  const handleUploadStart = ({ file, key }) => {
    console.log("from onUploadStart, file:", file);
  };

  const handleUploadError = ({ file, key }) => {
    console.log("from onUploadError, file:", file);
  };

  return (
    <StorageManager
      acceptedFileTypes={["image/*"]}
      accessLevel="public"
      maxFileCount={10}
      onFileRemove={handleFileRemove}
      onUploadError={(error, { key, file }) => handleUploadError({ file, key })}
      onUploadSuccess={handleUploadSuccess}
      onUploadStart={handleUploadStart}
      processFile={processFile}
    />
  );
};

export default ImageUploader;

Console log output

from processFile, file: File {name: "img.png", ...}
from onUploadStart, file: undefined
from onUploadSuccess, file: undefined
from onFileRemove, file: undefined

Additional information and screenshots

Amplify Version:
"@aws-amplify/ui-react": "^6.1.4",
"@aws-amplify/ui-react-storage": "^3.1.3",

@github-actions github-actions bot added the pending-triage Issue is pending triage label Jun 18, 2024
@timngyn timngyn added Storage An issue or a feature-request for Storage Component StorageManager StorageManager related issue of feature request labels Jun 19, 2024
@timngyn timngyn self-assigned this Jun 19, 2024
@timngyn timngyn added investigating This issue is being investigated feature-request Request a new feature and removed investigating This issue is being investigated pending-triage Issue is pending triage labels Jun 19, 2024
@timngyn timngyn removed their assignment Jun 19, 2024
@calebpollman calebpollman changed the title file prop is undefined in callbacks in StorageManager [FR] provide file in callbacks in StorageManager Jul 2, 2024
@calebpollman calebpollman changed the title [FR] provide file in callbacks in StorageManager [FR] provide file to iStorageManager event callbacks Jul 2, 2024
@calebpollman calebpollman changed the title [FR] provide file to iStorageManager event callbacks [FR] provide file to StorageManager event callbacks Jul 2, 2024
@jacoblogan
Copy link
Contributor

thanks for creating this issue. We'll take this into consideration for our roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature Storage An issue or a feature-request for Storage Component StorageManager StorageManager related issue of feature request
Projects
None yet
Development

No branches or pull requests

3 participants