-
Notifications
You must be signed in to change notification settings - Fork 597
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
Requesting Upload/lib-storage full working example #2183
Comments
Hi @jereztech, I was getting a different error from the code above which was I made some minor changes to the code to use blob which works: The code: export default function App() {
return (
<View style={styles.container}>
<Button
title="UPLOAD EXPO IMAGE"
onPress={async () => {
let pickerResult = await openImagePicker();
const response = await fetch(pickerResult.uri);
const blob = await response.blob();
!pickerResult.cancelled && uploadFile(
'avatars',
{
uri: pickerResult.uri,
name: 'img001',
type: pickerResult.type,
blob: blob
}
);
}} />
</View>
);
}
const uploadFile = async (bucketName, image) => {
try {
const _upload = new Upload({
client: client,
params: { Bucket: bucketName, Key: image.name, Body: image.blob },
});
_upload.on("httpUploadProgress", (progress) => console.log(progress.loaded));
return await _upload.done();
} catch (error) {
console.log(error);
throw new Error(error.message);
}
} Please let us know if that doesn't work as I was able to successfully upload an image with that. |
Hi @ajredniwja thanks a lot for reply. Unfortunately it's not working. I'm taking the following error: |
@ajredniwja FYI I'm having the same issue however changing to blob, like in your example doesn't fix the error for me. I still get |
I have the exact same issue, but on the browser (react app / Safari) I get the file from an // file is a File from the input
const client = new S3({
region,
credentials: {
accessKeyId,
secretAccessKey,
},
})
const params = {
Bucket: bucketName,
Key: pathToFile,
Body: file,
ACL: 'public-read',
ContentType:file.type,
}
const upload = new Upload({
client,
queueSize: 3,
params,
})
upload.on('httpUploadProgress', progress => {
if (progress.loaded && progress.total) {
const uploaded = Math.round(progress.loaded / progress.total * 100)
onUploadProgress(uploaded)
}
})
const data = await upload.done() I also tried to "rebuild" the blob with the following but without success const buffer = await file.arrayBuffer()
const blob = new Blob([new Uint8Array(buffer)], { type: file.type })
// send the blob @ajredniwja Do you have any idea/solution ? |
@jereztech @ludwighen I am successfully able to upload an image using the code above, can you guys check you are on the latest version? If possible set up a repo with your code which I can use to reproduce the code. @bmichotte I have seen this issue with safari: #2145 I am working on it, will have inputs soon. |
Hi @ajredniwja, I'm using the latest version |
same issue with safari. Latest version. upload on chrome etc. works fine. ` const buffer = await file.arrayBuffer();
|
@ludwighen Will track the safari issue with #2145, I'd close this issue now @jereztech, please reach out if you have any other questions. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Describe the bug
Upload an image from expo app not working.
Your environment
aws-sdk/[email protected]
aws-sdk/[email protected],
aws-sdk/[email protected],
aws-sdk/[email protected],
aws-sdk/[email protected],
[email protected]
[email protected]
[email protected]
[email protected]
Steps to reproduce
Observed behavior
Upload an image from expo app not working.
Expected behavior
Upload an image from expo app.
Additional context
Error: Can't find variable: ReadableStream.
The text was updated successfully, but these errors were encountered: