Comments (15)
@satsin06 - If you used the Amplify Gen 1 CLI, unauthenticated users will only be able to upload to files in the "public/" directory. Please try uploading a file to that directory.
Amplify Gen 2 allows for more flexible storage authorization. You can read more about Gen 2 storage here: https://docs.amplify.aws/flutter/build-a-backend/storage/authorization/
The Gen 2 docs currently have a callout that it is not available Flutter yet. It is available as long as you are using the Amplify Flutter v2 which was released recently.
from amplify-flutter.
Hello @androidshivam - Thanks for opening the issue. I have a few follow up questions to help us triage this.
Can you confirm that you created the S3 bucket with the Amplify CLI? The Amplify CLI allows your to set auth rules for guest and authenticated users. Can you let us know what rules you enabled?
Is there currently a user signed in when the issue occurs?
Can you update the code snippet as follows and share the logs?
Future<String?> uploadFile(io.File file) async {
try {
final awsFile = AWSFilePlatform.fromFile(file);
final uploadResult = await Amplify.Storage.uploadFile(
key: 'upload/file.jpeg',
localFile: awsFile,
options: StorageUploadFileOptions(
accessLevel: StorageAccessLevel.guest
),
onProgress: (progress) {
safePrint('Fraction completed: ${progress.fractionCompleted}');
},
).result;
safePrint('Uploaded file: ${uploadResult.uploadedItem.key}');
} on StorageException catch (e) {
safePrint('Could not retrieve properties: ${e.message}');
safePrint(e.underlyingException.statusCode);
safePrint(e.underlyingException.body);
safePrint(e.underlyingException.message);
safePrint(e.underlyingException.message);
safePrint(e.underlyingException.underlyingException);
rethrow;
}
}
from amplify-flutter.
Hello @Jordan-Nelson , I've created the bucket directly on browser using root user access and the changes in logs doesn't able found in library getting this error (The getter 'statusCode' isn't defined for the type 'Object'. )
safePrint(e.underlyingException.statusCode);
safePrint(e.underlyingException.body);
safePrint(e.underlyingException.message);
safePrint(e.underlyingException.message);
safePrint(e.underlyingException.underlyingException);
from amplify-flutter.
If you created the bucket manually have you followed these docs to import the bucket? Have you added the appropriate IAM policy?
If you are just getting started, I would recommend you use the CLI to create the bucket as it will set this up for you.
from amplify-flutter.
Hey, I've added the policies described in the docs for Auth roles and S3
I've started this project 4 years back using CLI but after some time I've to switch to different system i.e not able to setup the cli again
I'm able to get the presigned URL using this
final result = await Amplify.Storage.getUrl(
key: imageKey,
options: const StorageGetUrlOptions(
accessLevel: StorageAccessLevel.private,
pluginOptions: S3GetUrlPluginOptions(
expiresIn: Duration(days: 1),
),
),
).result;
But still can't able to render the image
getting Access denied error
from amplify-flutter.
Can you share your IAM policy?
from amplify-flutter.
Facing similar problem:
@Jordan-Nelson Please take a look into it
I tried setting up storage using amplify CLI and afterward I tried once using the one which I created manually, I don't want my users to go for authentication while uploading a photo
from amplify-flutter.
@Jordan-Nelson What should be the setting to confirm that it's a public directory?
from amplify-flutter.
@satsin06 the path should start with "public/". For example, StoragePath.fromString("public/file.txt")
from amplify-flutter.
@Jordan-Nelson still got same error:
from amplify-flutter.
@Jordan-Nelson Is there any example repository, which I can refer to?
from amplify-flutter.
@satsin06 - The path cannot be "public/" It should be a file inside the public directory. For example - "public/file.txt". There is a sample project here - https://github.com/aws-amplify/amplify-flutter/blob/main/packages/storage/amplify_storage_s3/example/lib/main.dart
You can also refer to the documentation for Gen 2 Storage which has example of uploading files to the public directory - https://docs.amplify.aws/flutter/build-a-backend/storage/upload-files/
from amplify-flutter.
@androidshivam - If you are still facing this issue please share some info about your IAM policy. Thanks.
from amplify-flutter.
@Jordan-Nelson Thanks for help
from amplify-flutter.
Hey @Jordan-Nelson , thanks for help.
from amplify-flutter.
Related Issues (20)
- Listen to Amplify.Hub events within Authenticator? HOT 3
- [amplify_secure_storage] Missing Apple Privacy Manifest HOT 3
- [Feature Request] Webassembly (Wasm) support in Amplify Flutter HOT 3
- [Feature Request] Support ampx --output-version 1 HOT 11
- Analytics record event is throwing SqliteException HOT 6
- Bump drift version to ^2.18.0 HOT 5
- AWSHttpRequest body creation fails on web HOT 1
- DataStore subscription not working with contains HOT 3
- Auth.signInWithWebUI with AuthProvider.custom redirect URI issue HOT 11
- Datastore error handler has unparsable error message HOT 1
- Model parsing fails for complex non-model types HOT 2
- [Datastore errorhandler] Incorporate a variable in error object to obtain the initial request. HOT 1
- web app, import amplify_storage_s3.dart cause drift-2.14.1/lib/src/web/wasm_setup/shared.dart The argument type 'LegacySyncFileHandle' can't be assigned to the parameter type 'Object' because 'LegacySyncFileHandle' is nullable and 'Object' isn't. HOT 5
- Pinpoint Notifications always use APNs Sandbox channel HOT 11
- Login with email is slow HOT 18
- Amplify Fails to Configure - WorkerBeeExceptionImpl HOT 5
- AmplifyAPI modelProvider not working moving from v1 to v2 HOT 2
- NotAuthorizedServiceException when answering NEW_PASSWORD_REQUIRED challenge HOT 7
- Amplify.Hub.listen never get "ready" HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-flutter.