Skip to content

Commit

Permalink
fix: Update Avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtesch9 committed Jun 19, 2020
1 parent 7340736 commit e44889e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mobile/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ android.useAndroidX=true
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.33.1
FLIPPER_VERSION=0.47.0
13 changes: 10 additions & 3 deletions mobile/src/pages/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,26 @@ const SignUp: React.FC = () => {
return;
}

const imageType = response.fileName?.split('.')[1];

const data = new FormData();

data.append('avatar', {
type: 'multipart/form-data',
name: `${user.id}-${response.fileName}`,
uri: response.uri,
name: `${user.id}-${response.fileName}`,
type: `image/${imageType}`,
});

try {
const apiResponse = await api.patch('/users/avatar', data);
const apiResponse = await api.patch('/users/avatar', data, {
headers: {
'Access-Control-Allow-Methods': 'PATCH',
},
});

updateUser(apiResponse.data);
} catch (err) {
console.log(err);
Alert.alert('Ocorreu um erro', 'Tente novamente');
}
},
Expand Down

0 comments on commit e44889e

Please sign in to comment.