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

add intial path to StorageBrowser #6325

Open
2 tasks
ajishab opened this issue Jan 29, 2025 · 3 comments
Open
2 tasks

add intial path to StorageBrowser #6325

ajishab opened this issue Jan 29, 2025 · 3 comments
Labels
Documentation An issue or a feature-request for our Amplify UI Doc site or AWS Amplify docs feature-request Request a new feature StorageBrowser

Comments

@ajishab
Copy link

ajishab commented Jan 29, 2025

On which framework/platform would you like to see this feature implemented?

React

Which UI component is this feature-request for?

Storage

Please describe your feature-request in detail.

with the native s3 console I can share links to subfolders, with storage browser it always refreshes at the base level (all configured paths). I would like to be able to browse to a subpath automatically based on URL.

Please describe a solution you'd like.

I want to use a react router to define the path to display in storage browser. eg vs storage browser starting at the at base level.

We love contributors! Is this something you'd be interested in working on?

  • 👋 I may be able to implement this feature request.
  • ⚠️ This feature might incur a breaking change.
@ajishab ajishab added the feature-request Request a new feature label Jan 29, 2025
@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify UI maintainer labels Jan 29, 2025
@calebpollman
Copy link
Member

Hi @ajishab is your project using the predefined StorageBrowser or createStorageBrowser? For example:

// predefined StorageBrowser
import { StorageBrowser } from '@aws-amplify/ui-react-storage';

// createStorageBrowser
import { createStorageBrowser } from '@aws-amplify/ui-react-storage/browser';

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify UI maintainer label Jan 29, 2025
@ajishab
Copy link
Author

ajishab commented Feb 3, 2025

@calebpollman we are using createStorageBrowser and specifiying S3 via amplif configure, with below code. Basically, we want to add a path from react router (or even query param) to the page and have it so that if a path is specified, it loads the bucket in the specified folder vs at the root. The use case is we want to be able to send users a link to a particular folder that they are actively working on, vs having to send them a link and tell them to goto a particular folder within the link. For now its just ease of use and we dont care if users can still navigate to other folders within the bucket, but that would be something we would like to do in the future as well.

Amplify.configure({
  Auth: {
    Cognito: {
  // https://docs.amplify.aws/lib/auth/getting-started/q/platform/js/#set-up-backend-resources
      userPoolId: "us-east-1=redacted", // import.meta.env.VITE_USER_POOL_ID,
      userPoolClientId: "redacted", // import.meta.env.VITE_USER_POOL_CLIENT_ID,
      identityPoolId: "redacted", // import.meta.env.VITE_IDENTITY_POOL_ID,
      allowGuestAccess: false,
      loginWith:{
        email: true
      },
    }
},
Storage: {
  S3: {
    bucket: 'shared-root-bucket,
    region: 'us-east-1',
    buckets: {
      "shared-root-bucketiI: {
        bucketName: 'shared-root-bucket',
        region: 'us-east-1',
        paths: {
          "": {
            // ↓ working.
            "guest": ["read"],
            "authenticated": ["read", "write"]
          }
        }
      }
    }
  },
},
})


const { StorageBrowser } = createStorageBrowser({
  config: createAmplifyAuthAdapter(),
  
});

const S3Viewer: React.FC = () => {
  const { path = '' } = useParams<{ path: string }>();

  return (
    <div style={{ padding: '20px', fontFamily: 'Arial, sans-serif' }}>
              <h1>Contents of S3 Path: /{path || 'root'}</h1>
    </div>
  );
};

const App: React.FC = () => (
  <Authenticator variation="modal">
    {({ signOut, user }) => (
      <Router>
        <Routes>
          <Route path="/:path*" element={<S3Viewer />} />
          <Route path="/" element={<S3Viewer />} />
        </Routes>
        <h1>Hello {user.username}</h1>
        <StorageBrowser />
        <button onClick={signOut}>Sign Out</button>
      </Router>
    )}
  </Authenticator>
);

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify UI maintainer label Feb 3, 2025
@cwomack cwomack added Documentation An issue or a feature-request for our Amplify UI Doc site or AWS Amplify docs StorageBrowser and removed pending-triage Issue is pending triage labels Feb 4, 2025
@cwomack
Copy link
Member

cwomack commented Feb 7, 2025

@ajishab, we're marking this as a documentation feature request because we need to improve the docs to provide instructions on how to do this. This is available out of the box with StorageBrowser, but want to document the proper way to set this up. We'll provide a PR linked soon with the documentation updates when ready. Thanks!

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify UI maintainer label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation An issue or a feature-request for our Amplify UI Doc site or AWS Amplify docs feature-request Request a new feature StorageBrowser
Projects
None yet
Development

No branches or pull requests

3 participants