HomeiOS Developmentandroid - Importing Rails Photos to a Distant Server

android – Importing Rails Photos to a Distant Server


I’ve acquired a little bit of a dilemma… I’ve a Rails (7.0) app and a cell (Android, iPhone) app. The cell app got here first. So it is already loaded with customers and pictures. To get round that impediment I simply exported the database tables for the images and imported them into the Rails database. The pictures are them loaded from that authentic server as such:

<% Picture.order("created_at desc").every do |c| %>

              <div class="col-md-4 col-sm-12 col-xs-12">
                <div class="campaign-item">

                  <%= link_to image_tag('https://awesomesite.com/uploads/' + c.uid.to_s + "https://stackoverflow.com/" + c.picture, gravity: 'middle', dimension: '370x240', crop: "pad"), c, class: 'overlay' %>
                  <div class="campaign-box">
                    <h3> <%= link_to c.title, c %> </h3>
                    </div>




            </div>
          </div>
          <% finish %>
          </div>

All good within the hood… till I spotted that, on the subject of making a NEW photograph… it is not going to add them to the identical place. It will add them to lively storage which is related to my Amazon Cloud server. This creates TWO issues as a result of 1. The cell app customers will not be capable of see the Rails images as a result of, not solely will the photographs not be there, however there will not even be a document of them within the distant database and a couple of. The Rails customers will not be capable of see them both as a result of it is setup to look on the distant server for the images.

How one can overcome this impediment?

Both I have to discover a method to add the photographs from Rails to the cell server (within the location above) utilizing the next API:

add.php

$fp1 = isset($_GET['uid']) ? $_GET['uid'] : "";
        $fp9 = isset($_GET['eid']) ? $_GET['eid'] : "";
        $maxWidth = 1080;
        $maxHeight = 1920;
        $file_path = "/var/www/superior/uploads/" . $fp1 . "/";
        $query_search = "INSERT INTO Photographs (photographer,title,description, uid, picture,) VALUES ('$title','$title','$desc','$fp1','$file_name')";
if (!file_exists($file_path)) {
                        mkdir($file_path, 0777, true);
                }
                $basePath = $file_path;
                $file_path = $file_path . basename( $_FILES['uploaded_file']['name']);
                if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path)) {
                        $file_resize_info_array = array();

                        //1080x1920
                        $file_resize_info = new FileResizeInfo();
                        $file_resize_info->listing = $basePath;
                        $file_resize_info->maxWidth = $maxWidth;
                        $file_resize_info->maxHeight = $maxHeight;
                        $file_resize_info->compressionPercentage = 90;
                        $file_resize_info_array[] = $file_resize_info;

                        //resize the picture
                        resize_images($file_resize_info_array, $basePath, $_FILES['uploaded_file']['name']);

                        $query_exec = mysqli_query($con, $query_search)

…or I have to discover a method to add the presently present information to lively storage and in some way get my Android and Rails apps to learn the brand new areas.

I might wish to know learn how to accomplish each of this stuff so I can determine which might be greatest for my setup. I am positively leaning in direction of the answer of sending the information via the identical api the cell app makes use of… as a result of that may be only a matter of determining learn how to ship the shape knowledge to the distant php file.

…although I also can see the benefits of getting the cell app the learn lively actorage…

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments