Skip to content

Instantly share code, notes, and snippets.

@dev-yohan
Created August 26, 2013 22:14
Show Gist options
  • Save dev-yohan/6347311 to your computer and use it in GitHub Desktop.
Save dev-yohan/6347311 to your computer and use it in GitHub Desktop.
#POST /v1/users/{id}/profile_photo
def create
user = User.where(_id: params[:id]).first
app_decorator = ApplicationDecorator.new(User)
if !user.nil?
user_decorated = UserDecorator.decorate(user)
user.convert_base64_image(params[:image],"image/png")
if user.save
render :json => user_decorated.profile_photo.to_json, :status => 201
else
render :json => app_decorator.error_message(user.errors,
I18n.t('api_v1_profile_photo.create.user_message'), "1004", "").to_json, :status => 404
end
else
render :json => app_decorator.error_message(I18n.t('api_v1_users.show.developer_message', :id => params[:id]),
I18n.t('api_v1_users.show.user_message'), "1002", "").to_json, :status => 404
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment