{"id":1712,"date":"2017-05-07T17:18:26","date_gmt":"2017-05-07T08:18:26","guid":{"rendered":"http:\/\/lovelinux.mydns.jp\/?p=1712"},"modified":"2017-05-07T17:18:26","modified_gmt":"2017-05-07T08:18:26","slug":"react-native%e3%81%a7%e3%82%ab%e3%83%a1%e3%83%a9%e3%83%ad%e3%83%bc%e3%83%ab%e3%82%92%e4%b8%80%e8%a6%a7%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%a6%e3%80%81%e9%81%b8%e6%8a%9e%e3%81%97%e3%81%9f%e7%94%bb","status":"publish","type":"post","link":"https:\/\/lovelinux.mydns.jp\/?p=1712","title":{"rendered":"React Native\u3067\u30ab\u30e1\u30e9\u30ed\u30fc\u30eb\u3092\u4e00\u89a7\u8868\u793a\u3057\u3066\u3001\u9078\u629e\u3057\u305f\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b"},"content":{"rendered":"<h3>\u306f\u3058\u3081\u306b<\/h3>\n<p>React Native\u3067\u30ab\u30e1\u30e9\u30ed\u30fc\u30eb\u3092\u3044\u3058\u308b\u65b9\u6cd5\u304c\u308f\u304b\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u8abf\u3079\u307e\u3057\u305f\u3002<br \/>\n\u3064\u3044\u3067\u306b\u3001\u4e00\u89a7\u8868\u793a\u3057\u305f\u753b\u50cf\u304b\u3089\u3001\u8907\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3057\u3001axios\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306fRails\u3067\u53d7\u3051\u53d6\u308b\u30bd\u30fc\u30b9\u3092\u306e\u3063\u3051\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u5168\u30bd\u30fc\u30b9\u3092\u8cbc\u308a\u4ed8\u3051\u307e\u3059\u3002<br \/>\n\u8aac\u660e\u306f\u90e8\u5206\u90e8\u5206\u304b\u3044\u3064\u307e\u3093\u3067\u884c\u3044\u307e\u3059\u3002<\/p>\n<h3>CameraRoll\u304b\u3089\u753b\u50cf\u4e00\u89a7\u53d6\u5f97<\/h3>\n<p>\u30ab\u30e1\u30e9\u30ed\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u3001<br \/>\n[bash]<br \/>\nimport {<br \/>\n  CameraRoll,<br \/>\n} from &#8220;react-native&#8221;<br \/>\n[\/bash]<\/p>\n<p>componentDidMount\u3067\u4e00\u89a7\u3092\u53d6\u5f97\u3057\u3001State\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<br \/>\nimageSel\u306f\u753b\u50cf\u304c\u9078\u629e\u3055\u308c\u305f\u304b\u3069\u3046\u304b\u306e\u30d5\u30e9\u30b0\u3067\u3059\u3002<\/p>\n<p>[bash]<\/p>\n<p>  componentDidMount() {<br \/>\n    let svThis = this<br \/>\n    CameraRoll.getPhotos({first:25})<br \/>\n      .then(function(obj){<br \/>\n        console.log(obj)<br \/>\n        svThis.storeImages(obj.edges, svThis)<br \/>\n      })<br \/>\n  }<\/p>\n<p>  storeImages(edges,svThis) {<br \/>\n    const images = edges.map((asset) => {<br \/>\n      \/\/Alert.alert(asset.node.image.uri)<br \/>\n      return asset.node.image<br \/>\n    })<\/p>\n<p>    let imgSel = []<br \/>\n    images.map((img) => {<br \/>\n      imgSel.push({uri: img.uri, selected: false})<br \/>\n    })<\/p>\n<p>    svThis.setState({images: images, imageSel: imgSel})<br \/>\n  }<\/p>\n<p>[\/bash]<\/p>\n<h3>\u753b\u50cf\u4e00\u89a7\u8868\u793a<\/h3>\n<p>render\u30e1\u30bd\u30c3\u30c9\u3067\u4e00\u89a7\u8868\u793a\u3057\u307e\u3059\u3002<br \/>\n\u753b\u50cf\u3092TouchableHighlight\u30bf\u30b0\u306e\u4e2d\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\u753b\u50cf\u304c\u9078\u629e\u3055\u308c\u3066\u3044\u308b\u304b\u5426\u304b\u3092 selView\u3068\u3044\u3046\u5909\u6570\u306b\u30bb\u30c3\u30c8\u3057\u3066\u3001<br \/>\n\u9078\u629e\u4e2d\u306e\u753b\u50cf\u306b\u30c1\u30a7\u30c3\u30af\u304c\u3064\u304f\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>[bash]<\/p>\n<p>  render() {<br \/>\n    let imgs = []<br \/>\n    imgs = this.state.images.map((img) => {<\/p>\n<p>      let selTrue = false<br \/>\n      let selView = null<br \/>\n      this.state.imageSel.map((sel) => {<br \/>\n        if (sel.uri == img.uri &#038;&#038; sel.selected == true){<br \/>\n          selTrue = true<br \/>\n        }<br \/>\n      })<\/p>\n<p>      if (selTrue){<br \/>\n        selView = (<br \/>\n          <View style={styles.imageSel}><br \/>\n            <Image\n              style={styles.check}\n              source={require(\"..\/images\/check.png\")}\n            \/><br \/>\n          <\/View><br \/>\n        )<br \/>\n      }<\/p>\n<p>      return (<br \/>\n        <TouchableHighlight\n          style={styles.tphoto}\n          key={img.uri}\n          onPress={() => this.handleClick(img)}><br \/>\n          <View><br \/>\n            <Image style={styles.image} source={{uri: img.uri}} \/><br \/>\n            {selView}<br \/>\n          <\/View><br \/>\n        <\/TouchableHighlight><br \/>\n      )<br \/>\n    })<\/p>\n<p>    return (<br \/>\n      <View style={styles.container}><br \/>\n        <Text><br \/>\n          {this.state.selPhoto}<br \/>\n        <\/Text><br \/>\n        <Button\n          onPress={() => this.handleUpload()}<br \/>\n          title=&#8221;Upload&#8221;<br \/>\n        \/><br \/>\n        <ScrollView><br \/>\n          <View style={styles.imageGrid} ><br \/>\n            {imgs}<br \/>\n          <\/View><br \/>\n        <\/ScrollView><br \/>\n      <\/View><br \/>\n    )<br \/>\n  }<\/p>\n<p>[\/bash]<\/p>\n<h3>\u753b\u50cf\u304c\u9078\u629e\u3055\u308c\u305f\u3089\u3001\u30c1\u30a7\u30c3\u30af\u30de\u30fc\u30af\u3092\u3064\u3051\u308b<\/h3>\n<p>\u753b\u50cf\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3089\u3001\u30b9\u30c6\u30fc\u30c8\u306e\u30d5\u30e9\u30b0\u3092\u305f\u3066\u304b\u3048\u3066\u3001\u30c1\u30a7\u30c3\u30af\u30de\u30fc\u30af\u3092\u3064\u3051\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n  handleClick(img) {<br \/>\n    let imgSel = this.state.imageSel.map((sel) => {<br \/>\n      if (sel.uri == img.uri){<br \/>\n        sel.selected = !sel.selected<br \/>\n      }<br \/>\n      return sel<br \/>\n    })<\/p>\n<p>    this.setState({imageSel: imgSel, selPhoto: img.uri})<br \/>\n  }<\/p>\n<p>[\/bash]<br \/>\n<a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/05\/cameraroll-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/05\/cameraroll-1.png\" alt=\"cameraroll-1\" width=\"405\" height=\"820\" class=\"alignnone size-full wp-image-1713\" \/><\/a><\/p>\n<h3>\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u3092axios\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/h3>\n<p>\u6ce8\u610f\u3059\u3079\u304d\u70b9\u306f\u3001data.append\u3059\u308b\u3068\u304d\u306b uri\u3068 name \u3068 type\u306e3\u3064\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>[bash]<\/p>\n<p>  handleUpload(){<br \/>\n    let data = new FormData()<br \/>\n    let cnt = 1<br \/>\n    this.state.imageSel.map((sel) => {<br \/>\n      if (sel.selected){<br \/>\n        data.append(&#8220;file_&#8221; + cnt, {uri: sel.uri ,name: &#8220;photo_&#8221; + cnt + &#8220;.jpg&#8221;,type:&#8221;image\/jpg&#8221;})<br \/>\n        cnt += 1<br \/>\n      }<br \/>\n    })<\/p>\n<p>    let REQ_URI = &#8220;http:\/\/192.168.11.3:3000\/upload_image_from_native&#8221;<br \/>\n    axios.post(REQ_URI,data)<br \/>\n      .then(function(res){<br \/>\n        Alert.alert(&#8220;good&#8221;)<br \/>\n      })<br \/>\n      .catch(function(err){<br \/>\n        console.log(err)<br \/>\n      })<br \/>\n  }<\/p>\n<p>[\/bash]<\/p>\n<h3>\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f\u753b\u50cf\u3092\u4fdd\u5b58\u3059\u308b\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9(Rails)\u306e\u30bd\u30fc\u30b9<\/h3>\n<p>[bash]<br \/>\ndef upload_image_from_native<br \/>\n  image_path = Rails.root.to_s + &#8220;\/public\/upload_images\/reactnative&#8221;<br \/>\n  FileUtils.mkdir_p(image_path) unless FileTest.exist?(image_path)<\/p>\n<p>  pp &#8220;************** params *******************&#8221;<br \/>\n  pp params<\/p>\n<p>  cnt = 1<br \/>\n  while true do<br \/>\n    break if params[&#8220;file_&#8221; + cnt.to_s].blank?<br \/>\n    file = params[&#8220;file_&#8221; + cnt.to_s]<br \/>\n    fname = file.original_filename<\/p>\n<p>    File.open(image_path + &#8220;\/#{fname}&#8221;, &#8216;wb&#8217;) { |f|<br \/>\n      f.write(file.read)<br \/>\n    }<br \/>\n    cnt += 1<br \/>\n  end<\/p>\n<p>end<\/p>\n<p>[\/bash]<\/p>\n<h3>\u5168\u30bd\u30fc\u30b9<\/h3>\n<p>\u4ee5\u4e0b\u306b\u5168\u30bd\u30fc\u30b9\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\nimport React from &#8220;react&#8221;<\/p>\n<p>import {<br \/>\n  StyleSheet,<br \/>\n  Text,<br \/>\n  View,<br \/>\n  ScrollView,<br \/>\n  Image,<br \/>\n  CameraRoll,<br \/>\n  Alert,<br \/>\n  TouchableHighlight,<br \/>\n  Button,<br \/>\n} from &#8220;react-native&#8221;<\/p>\n<p>import axios from &#8220;axios&#8221;<\/p>\n<p>class App extends React.Component {<br \/>\n  constructor(props){<br \/>\n    super(props)<br \/>\n    this.state = {images: [], imageSel: [], selPhoto: &#8220;&#8221;}<br \/>\n  }<\/p>\n<p>  componentDidMount() {<br \/>\n    let svThis = this<br \/>\n    CameraRoll.getPhotos({first:25})<br \/>\n      .then(function(obj){<br \/>\n        console.log(obj)<br \/>\n        svThis.storeImages(obj.edges, svThis)<br \/>\n      })<br \/>\n  }<\/p>\n<p>  storeImages(edges,svThis) {<br \/>\n    const images = edges.map((asset) => {<br \/>\n      \/\/Alert.alert(asset.node.image.uri)<br \/>\n      return asset.node.image<br \/>\n    })<\/p>\n<p>    let imgSel = []<br \/>\n    images.map((img) => {<br \/>\n      imgSel.push({uri: img.uri, selected: false})<br \/>\n    })<\/p>\n<p>    svThis.setState({images: images, imageSel: imgSel})<br \/>\n  }<\/p>\n<p>  logImageError(err) {<br \/>\n    console.log(err)<br \/>\n  }<\/p>\n<p>  handleClick(img) {<br \/>\n    let imgSel = this.state.imageSel.map((sel) => {<br \/>\n      if (sel.uri == img.uri){<br \/>\n        sel.selected = !sel.selected<br \/>\n      }<br \/>\n      return sel<br \/>\n    })<\/p>\n<p>    this.setState({imageSel: imgSel, selPhoto: img.uri})<br \/>\n  }<\/p>\n<p>  handleUpload(){<br \/>\n    let data = new FormData()<br \/>\n    let cnt = 1<br \/>\n    this.state.imageSel.map((sel) => {<br \/>\n      if (sel.selected){<br \/>\n        data.append(&#8220;file_&#8221; + cnt, {uri: sel.uri ,name: &#8220;photo_&#8221; + cnt + &#8220;.jpg&#8221;,type:&#8221;image\/jpg&#8221;})<br \/>\n        cnt += 1<br \/>\n      }<br \/>\n    })<\/p>\n<p>    let REQ_URI = &#8220;http:\/\/192.168.11.3:3000\/upload_image_from_native&#8221;<br \/>\n    axios.post(REQ_URI,data)<br \/>\n      .then(function(res){<br \/>\n        Alert.alert(&#8220;good&#8221;)<br \/>\n      })<br \/>\n      .catch(function(err){<br \/>\n        console.log(err)<br \/>\n      })<br \/>\n  }<\/p>\n<p>  render() {<br \/>\n    let imgs = []<br \/>\n    imgs = this.state.images.map((img) => {<\/p>\n<p>      let selTrue = false<br \/>\n      let selView = null<br \/>\n      this.state.imageSel.map((sel) => {<br \/>\n        if (sel.uri == img.uri &#038;&#038; sel.selected == true){<br \/>\n          selTrue = true<br \/>\n        }<br \/>\n      })<\/p>\n<p>      if (selTrue){<br \/>\n        selView = (<br \/>\n          <View style={styles.imageSel}><br \/>\n            <Image\n              style={styles.check}\n              source={require(\"..\/images\/check.png\")}\n            \/><br \/>\n          <\/View><br \/>\n        )<br \/>\n      }<\/p>\n<p>      return (<br \/>\n        <TouchableHighlight\n          style={styles.tphoto}\n          key={img.uri}\n          onPress={() => this.handleClick(img)}><br \/>\n          <View><br \/>\n            <Image style={styles.image} source={{uri: img.uri}} \/><br \/>\n            {selView}<br \/>\n          <\/View><br \/>\n        <\/TouchableHighlight><br \/>\n      )<br \/>\n    })<\/p>\n<p>    return (<br \/>\n      <View style={styles.container}><br \/>\n        <Text><br \/>\n          {this.state.selPhoto}<br \/>\n        <\/Text><br \/>\n        <Button\n          onPress={() => this.handleUpload()}<br \/>\n          title=&#8221;Upload&#8221;<br \/>\n        \/><br \/>\n        <ScrollView><br \/>\n          <View style={styles.imageGrid} ><br \/>\n            {imgs}<br \/>\n          <\/View><br \/>\n        <\/ScrollView><br \/>\n      <\/View><br \/>\n    )<br \/>\n  }<br \/>\n}<\/p>\n<p>const styles = StyleSheet.create({<br \/>\n  container: {<br \/>\n    flex: 1,<br \/>\n    backgroundColor: &#8216;#F5FCFF&#8217;,<br \/>\n  },<br \/>\n  imageGrid: {<br \/>\n    flex: 1,<br \/>\n    flexDirection: &#8216;row&#8217;,<br \/>\n    flexWrap: &#8216;wrap&#8217;,<br \/>\n    justifyContent: &#8216;center&#8217;<br \/>\n  },<br \/>\n  image: {<br \/>\n    width: 100,<br \/>\n    height: 100,<br \/>\n    margin: 10,<br \/>\n  },<br \/>\n  imageSel: {<br \/>\n    position: &#8220;absolute&#8221;,<br \/>\n    top: 15,<br \/>\n    left: 15,<br \/>\n  },<br \/>\n  check: {<br \/>\n    height: 20,<br \/>\n    width: 20,<br \/>\n  }<br \/>\n})<\/p>\n<p>export default App<\/p>\n<p>[\/bash]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b React Native\u3067\u30ab\u30e1\u30e9\u30ed\u30fc\u30eb\u3092\u3044\u3058\u308b\u65b9\u6cd5\u304c\u308f\u304b\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u8abf\u3079\u307e\u3057\u305f\u3002 \u3064\u3044\u3067\u306b\u3001\u4e00\u89a7\u8868\u793a\u3057\u305f\u753b\u50cf\u304b\u3089\u3001\u8907\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3057\u3001axios\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306fRails\u3067\u53d7\u3051\u53d6\u308b\u30bd\u30fc\u30b9\u3092\u306e\u3063\u3051\u3066\u304a\u304d\u307e\u3059\u3002 \u6700\u5f8c\u306b\u5168\u30bd\u30fc\u30b9\u3092\u8cbc\u308a\u4ed8\u3051\u307e\u3059\u3002 \u8aac\u660e\u306f\u90e8\u5206\u90e8\u5206\u304b\u3044\u3064\u307e\u3093\u3067\u884c\u3044\u307e\u3059\u3002 CameraRoll\u304b\u3089\u753b\u50cf\u4e00\u89a7\u53d6\u5f97 \u30ab\u30e1\u30e9\u30ed\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u3001 [bash] import { CameraRoll, } from &#8220;react-native&#8221; [\/bash] componentDidMount\u3067\u4e00\u89a7\u3092\u53d6\u5f97\u3057\u3001State\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002 imageSel\u306f\u753b\u50cf\u304c\u9078\u629e\u3055\u308c\u305f\u304b\u3069\u3046\u304b\u306e\u30d5\u30e9\u30b0\u3067\u3059\u3002 [bash] componentDidMount() { let svThis = this CameraRoll.getPhotos({first:25}) .then(function(obj){ console.log(obj) svThis.storeImages(obj.edges, svThis) }) } storeImages(edges,svThis) { const images = edges.map((asset) => { \/\/Alert.alert(asset.node.image.uri) return asset.node.image }) let imgSel = [] images.map((img) => { imgSel.push({uri: img.uri, selected: false}) }) svThis.setState({images: images, imageSel: imgSel}) } [\/bash] \u753b\u50cf\u4e00\u89a7\u8868\u793a render\u30e1\u30bd\u30c3\u30c9\u3067\u4e00\u89a7\u8868\u793a\u3057\u307e\u3059\u3002 \u753b\u50cf\u3092TouchableHighlight\u30bf\u30b0\u306e\u4e2d\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\u753b\u50cf\u304c\u9078\u629e\u3055\u308c\u3066\u3044\u308b\u304b\u5426\u304b\u3092 selView\u3068\u3044\u3046\u5909\u6570\u306b\u30bb\u30c3\u30c8\u3057\u3066\u3001 \u9078\u629e\u4e2d\u306e\u753b\u50cf\u306b\u30c1\u30a7\u30c3\u30af\u304c\u3064\u304f\u3088\u3046\u306b\u3057\u307e\u3059\u3002 [bash] render() { let imgs = [] imgs = this.state.images.map((img) => { let selTrue = false let selView = null this.state.imageSel.map((sel) => { if (sel.uri == img.uri &#038;&#038; sel.selected == true){ selTrue = true } }) if (selTrue){ selView = ( ) } return ( this.handleClick(img)}> {selView} ) }) return ( {this.state.selPhoto} this.handleUpload()} title=&#8221;Upload&#8221; \/> {imgs} ) } [\/bash] \u753b\u50cf\u304c\u9078\u629e\u3055\u308c\u305f\u3089\u3001\u30c1\u30a7\u30c3\u30af\u30de\u30fc\u30af\u3092\u3064\u3051\u308b \u753b\u50cf\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3089\u3001\u30b9\u30c6\u30fc\u30c8\u306e\u30d5\u30e9\u30b0\u3092\u305f\u3066\u304b\u3048\u3066\u3001\u30c1\u30a7\u30c3\u30af\u30de\u30fc\u30af\u3092\u3064\u3051\u307e\u3059\u3002 [bash] handleClick(img) { let imgSel = this.state.imageSel.map((sel) => { if (sel.uri == img.uri){ sel.selected = !sel.selected } return sel }) this.setState({imageSel: imgSel, selPhoto: img.uri}) } [\/bash] \u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u3092axios\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9 \u6ce8\u610f\u3059\u3079\u304d\u70b9\u306f\u3001data.append\u3059\u308b\u3068\u304d\u306b uri\u3068 name \u3068 type\u306e3\u3064\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3053\u3068\u3067\u3059\u3002 [bash] handleUpload(){ let data = new FormData() let cnt = 1 this.state.imageSel.map((sel) => { if (sel.selected){ data.append(&#8220;file_&#8221; + cnt, {uri: sel.uri ,name: &#8220;photo_&#8221; + cnt + &#8220;.jpg&#8221;,type:&#8221;image\/jpg&#8221;}) cnt += 1 } }) let REQ_URI = &#8220;http:\/\/192.168.11.3:3000\/upload_image_from_native&#8221; axios.post(REQ_URI,data) .then(function(res){ Alert.alert(&#8220;good&#8221;) }) .catch(function(err){ console.log(err) }) } [\/bash] \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f\u753b\u50cf\u3092\u4fdd\u5b58\u3059\u308b\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9(Rails)\u306e\u30bd\u30fc\u30b9 [bash] def upload_image_from_native image_path = Rails.root.to_s + &#8220;\/public\/upload_images\/reactnative&#8221; FileUtils.mkdir_p(image_path) unless FileTest.exist?(image_path) pp &#8220;************** params *******************&#8221; pp params cnt = 1 while true do break if params[&#8220;file_&#8221; + cnt.to_s].blank? file = params[&#8220;file_&#8221; + cnt.to_s] fname = file.original_filename File.open(image_path + &#8220;\/#{fname}&#8221;, &#8216;wb&#8217;) { |f| f.write(file.read) } cnt += 1 end end [\/bash] \u5168\u30bd\u30fc\u30b9 \u4ee5\u4e0b\u306b\u5168\u30bd\u30fc\u30b9\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u304a\u304d\u307e\u3059\u3002 [bash] import React from &#8220;react&#8221; import { StyleSheet, Text, View, ScrollView, Image, CameraRoll, Alert, TouchableHighlight, Button, } from &#8220;react-native&#8221; import axios from &#8220;axios&#8221; class App extends React.Component { constructor(props){ super(props) this.state = {images: [], imageSel: [], selPhoto: &#8220;&#8221;} } componentDidMount() {&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1714,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[77],"tags":[86,79],"class_list":{"0":"post-1712","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-react","8":"tag-react","9":"tag-react-native"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1712"}],"version-history":[{"count":1,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1712\/revisions"}],"predecessor-version":[{"id":1715,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1712\/revisions\/1715"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/media\/1714"}],"wp:attachment":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}