Comments (15)
@mattRiddoch can you confirm that value.path is indeed a valid file path before passing it to the uploadFile() API?
from amplify-flutter.
@Ashish-Nanda Here is what the path looks like:
/Users/mattriddoch/Library/Developer/CoreSimulator/Devices/F694C06D-4AEA-490F-BE99-CB8635D94192/data/Containers/Data/Application/2F52DFEB-FD29-4F4E-A364-EEB065717896/tmp/image_picker_26878D92-6B72-499F-BB77-8DE1FFF011FC-52750-0000DACF01486E63.jpg
The image is coming from the library via image_picker: ^0.6.7+4
in the simulator.
from amplify-flutter.
Hi @mattRiddoch
I think the issue is likely coming from the image_picker
library you're using. I've tried reproducing your error (using a different picker library) and have no issues uploading image files from my gallery on a iPhone SE emulator.
Could you try using the file_picker: ^1.8.0+1
in your pubspec.yaml instead to see if that works for you? We use that in our example app for picking files to upload.
from amplify-flutter.
The path of the file you provided seems fine, so not sure why you are getting the error. I also tried a clean setup today in an attempt to reproduce your issue and can confirm upload is working as expected. We are using the file_picker
library @fjnoyp mentioned above. Could you give that a try based on the code in our sample app?
Let us know if you still face issues.
from amplify-flutter.
OK! I brought in the file_picker
library and am using the following uploading snippet from the example code:
void upload() async {
try {
print('In upload');
// Uploading the file with options
File local = await FilePicker.getFile(type: FileType.image);
final key = new DateTime.now().toString();
Map<String, String> metadata = <String, String>{};
metadata['name'] = 'filename';
metadata['desc'] = 'A test file';
S3UploadFileOptions options = S3UploadFileOptions(
accessLevel: StorageAccessLevel.guest, metadata: metadata);
UploadFileResult result = await Amplify.Storage.uploadFile(
key: key, local: local, options: options);
print(result.key);
} catch (e) {
print('UploadFile Err: ' + e.toString());
}
}
Upon picking an asset I get the following error:
UploadFile Err: RangeError (index): Invalid value: Valid value range is empty: 0
I did set a breakpoint prior to the upload attempt and can confirm that a valid file is being passed in?
On a side note this is the exact same error I raise when I save a file to the documents folder and attempt to upload from there as well?
from amplify-flutter.
Hi @mattRiddoch it's strange the example code isn't working for you now as well. We've validated this code works so this issue could be related to your configuration.
Have you tried running the Amplify CLI to create a s3 bucket and performed an upload. Can you provide details on how you've generated your amplifyconfiguration.dart file?
from amplify-flutter.
@mattRiddoch can you share you amplifyconfiguration.dart file?
from amplify-flutter.
Sure thing @Ashish-Nanda
const amplifyconfig = ''' {
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"UserAgent": "aws-amplify-cli/0.1.0",
"Version": "0.1.0",
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": "<PoolId>
"Region": "us-east-1"
}
}
},
"CognitoUserPool": {
"Default": {
"PoolId": "<PoolId>",
"AppClientId": "<ClientId>",
"AppClientSecret": "<ClientSecret>",
"Region": "us-east-1"
}
},
"Auth": {
"Default": {
"authenticationFlowType": "USER_SRP_AUTH"
}
},
"PinpointAnalytics": {
"Default": {
"AppId": "<AppId>",
"Region": "us-east-1"
}
},
"PinpointTargeting": {
"Default": {
"Region": "us-east-1"
}
},
"S3TransferUtility": {
"Default": {
"Bucket": "<BucketId>
"Region": "us-east-1"
}
}
}
}
},
"analytics": {
"plugins": {
"awsPinpointAnalyticsPlugin": {
"pinpointAnalytics": {
"appId": "<AppId>",
"region": "us-east-1"
},
"pinpointTargeting": {
"region": "us-east-1"
}
}
}
},
"storage": {
"plugins": {
"awsS3StoragePlugin": {
"bucket": "<bucketId>",
"region": "us-east-1",
"defaultAccessLevel": "guest"
}
}
}
}''';
from amplify-flutter.
I am having an issue identical to this one - I am configured using the example Storage application and upon uploading I also get UploadFile Err: RangeError (index): Invalid value: Valid value range is empty: 0
from amplify-flutter.
You can try first getting a path of the file and store that in some variable then pass that value in uploadFile function like this
Hope it helps!
from amplify-flutter.
@Shrey29ansh I will give this a try soon. I have gotten a little sidetracked with other features but this is still very much an issue for me. Much appreciated.
from amplify-flutter.
Hey @mattRiddoch have you been able to resolve this issue?
from amplify-flutter.
I also got this error.
RangeError (index): Invalid value: Valid value range is empty: 0.
Now I have solved this error.
The reason was that the list "plugins" in the StorageCategory class was empty.
The problem is probably in the initial configuration of the plugins.
Here is the code before the fix.
// Add Pinpoint and Cognito Plugins
AmplifyAnalyticsPinpoint analyticsPlugin = AmplifyAnalyticsPinpoint();
AmplifyAuthCognito authPlugin = AmplifyAuthCognito();
amplifyInstance.addPlugin(authPlugins: [authPlugin]);
amplifyInstance.addPlugin(analyticsPlugins: [analyticsPlugin]);
AmplifyDataStore datastorePlugin =
AmplifyDataStore(modelProvider: ModelProvider.instance);
amplifyInstance.addPlugin(dataStorePlugins: [datastorePlugin]);
// Add this line, to include the Auth plugin.
AmplifyStorageS3 storage = AmplifyStorageS3();
amplifyInstance.addPlugin(
authPlugins: [authPlugin],
storagePlugins: [storage]
);
// Once Plugins are added, configure Amplify
await amplifyInstance.configure(amplifyconfig);
Here is the code after the fix.
// Add Pinpoint and Cognito Plugins
AmplifyAnalyticsPinpoint analyticsPlugin = AmplifyAnalyticsPinpoint();
AmplifyAuthCognito authPlugin = AmplifyAuthCognito();
AmplifyDataStore datastorePlugin =
AmplifyDataStore(modelProvider: ModelProvider.instance);
// Add this line, to include the Auth plugin.
AmplifyStorageS3 storage = AmplifyStorageS3();
amplifyInstance.addPlugin(
authPlugins: [authPlugin],
analyticsPlugins: [analyticsPlugin],
dataStorePlugins: [datastorePlugin],
storagePlugins: [storage]
);
// Once Plugins are added, configure Amplify
await amplifyInstance.configure(amplifyconfig);
from amplify-flutter.
Hey @mattRiddoch . Sorry for the late reply.
I tested in iOS, and Android and I couldn't reproduce the issue
Feel free to test using the latest build and let us know if you got any issues
Thanks
from amplify-flutter.
Hey @mattRiddoch
I am closing this issue for now as I didn't hear from you and I couldn't reproduce as per my comment above.
We can reopen it if you are still facing the issue and when you provide details
Regards
Mo
from amplify-flutter.
Related Issues (20)
- How to call Admin Queries API with authorization? HOT 1
- S3 access denied when making the API call. HOT 2
- No way to send unconfirmed user confirmation email when they restart the app HOT 5
- DataStore sync on Android physical devices takes very long time HOT 7
- Initial DataStore Sync Slow for Android Devices HOT 4
- fetchUserAttributes function cause toomanyrequestexception HOT 8
- AmplifyPushNotificationsPinpoint doesn't support offline configuration HOT 3
- Stuck in WebUI after authenticating with a certificate in iOS HOT 16
- Type comparison with UnderlyingExceptions might not be working as expected. HOT 5
- Update device_info_plus dependency HOT 2
- Update connectivity_plus dependency HOT 1
- Datastore without Cloud sync - Android build failing HOT 6
- Unable to get local issuer certificate when configure Amplify on Windows Devices HOT 7
- User cancelled OAuth flow error from signInWithRedirect
- Amplify confirm sign in with custom authentication flow timing out HOT 1
- Unauthorized error when Data-specific Authorization with AppSync (Datastore/GraphQL) HOT 6
- Flutter Web AmplifyAuthCognito SignOut not working HOT 7
- DataStore.observeQuery is not working when model has owner + static group auth rules HOT 2
- Flutter amplify dependency fails on apk build HOT 4
- Flutter - AWS Amplify - Network error in authentication when building apk, no issues in debug/emulation
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.