mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-03 00:15:14 +03:00
working on image uplaod
This commit is contained in:
parent
6908ea07ac
commit
97c0c6c4b1
@ -105,3 +105,53 @@ export const search = data => new Promise((resolve, reject) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
// Schedule
|
||||
export const schedule = (
|
||||
user,
|
||||
title,
|
||||
permlink,
|
||||
json,
|
||||
tags,
|
||||
body,
|
||||
operationType,
|
||||
upvote,
|
||||
scheduleDate,
|
||||
) => api
|
||||
.post('/api/schedules', {
|
||||
username: user,
|
||||
category: tags[0],
|
||||
title,
|
||||
permlink,
|
||||
json: JSON.stringify(json),
|
||||
tags,
|
||||
body,
|
||||
post_type: operationType,
|
||||
upvote_this: upvote,
|
||||
schedule: scheduleDate,
|
||||
chain: 'steem',
|
||||
})
|
||||
.then(resp => resp.data);
|
||||
|
||||
export const getSchedules = user => api.get(`/api/schedules/${user}`).then(resp => resp.data);
|
||||
|
||||
export const removeSchedule = (id, user) => api.delete(`/api/schedules/${user}/${id}`);
|
||||
|
||||
export const moveSchedule = (id, user) => api.put(`/api/schedules/${user}/${id}`);
|
||||
|
||||
// Images
|
||||
|
||||
export const getImages = user => api.get(`api/images/${user}`).then(resp => resp.data);
|
||||
|
||||
export const uploadImage = (file) => {
|
||||
const fData = new FormData();
|
||||
fData.append('postimage', file);
|
||||
|
||||
return api.post('https://img.esteem.ws/backend.php', fData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const addMyImage = (user, url) => api.post('/api/image', { username: user, image_url: url });
|
||||
|
@ -3,6 +3,7 @@ import { connect } from 'react-redux';
|
||||
import ImagePicker from 'react-native-image-crop-picker';
|
||||
|
||||
// Services and Actions
|
||||
import { uploadImage } from '../../../providers/esteem/esteem';
|
||||
import { postContent } from '../../../providers/steem/dsteem';
|
||||
import { setDraftPost, getDraftPost } from '../../../realm/realm';
|
||||
import { getDigitPinCode } from '../../../providers/steem/auth';
|
||||
@ -82,6 +83,8 @@ class ExampleContainer extends Component {
|
||||
height: 400,
|
||||
cropping: true,
|
||||
// multiple: true,
|
||||
writeTempFile: true,
|
||||
includeBase64: true,
|
||||
})
|
||||
.then((image) => {
|
||||
this._handleMediaOnSelected(image);
|
||||
@ -104,10 +107,14 @@ class ExampleContainer extends Component {
|
||||
this._handleMediaOnSelectFailure(e);
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: keyboard opening bug fixed
|
||||
_handleMediaOnSelected = (media) => {
|
||||
this.setState({ isCameraOrPickerOpen: false });
|
||||
console.log(media);
|
||||
uploadImage(media.data).then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
};
|
||||
|
||||
_handleMediaOnSelectFailure = (error) => {
|
||||
|
Loading…
Reference in New Issue
Block a user