问题
I am developing an application that sends images to be processed on the server. The server receives the captured image in the application and processes the image using opencv. Both the server and the application are already working and there is communication between both. The project folder, inside the server, already has all the permissions granted as shown in the image below. The problem is that when sending the application image, containing the default name 'final.png' for all images received on the server, permission is changed on the server side and, with this, the server cannot perform the processing and consequently the change in the image, as you no longer have the necessary permissions. Can anyone tell me why the image changes permissions when it is sent to the server, or how to resolve to grant all permissions again before the image is processed? I'm using the laravel framework for server development and my application is on native android.
directory of the algorithm to be processed the image, where the 'exec' is the algorithm that processes and the respective image.
Response API to send image:
After the image is sent to the server:
My code server:
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Process\Process;
class ClassificationController extends Controller
{
public function process(Request $request)
{
/** @var $image UploadedFile*/
$image = $request->files->get('image');
if (empty($image)) {
throw new \Exception("Arquivo não fornecido.");
}
$validExtensions = ['image/jpeg', 'image/png', 'image/jpg'];
if (!in_array($image->getMimeType(), $validExtensions)) {
dd($image->getMimeType());
throw new \Exception("Arquivo não suportado");
}
if (!$image->move(resource_path('feridas'), $image->getClientOriginalName())) {
throw new \Exception("Error moving file.");
}
$newPath = resource_path('feridas/' . $image->getClientOriginalName());
return $this->processImage($newPath);
}
private function processImage($newPath)
{
var_dump(__DIR__, realpath('.'), realpath('feridas/exec'));
$process = new Process([var_dump(getcwd())]);
$process->run();
$process->wait();
if (!$process->isSuccessful()) {
return [
'success' => true, //ou false
'message' => 'Could not execute script: %s', $process->getErrorOutput()
];
throw new ProcessFailedException($process);
}
$output = $process->getOutput();
$result = json_decode($output, true);
if (null === $result) {
return [
'success' => true, //ou false
'message' => 'Could not decode return value from script from template "%s" (should be a JSON encoded string): %s', $output
];
}
else{
return [
'success' => true, //ou false
'message' => "WORK"
];
}
}
}
来源:https://stackoverflow.com/questions/65483579/full-file-permission-is-changed-when-uploading-file-to-my-api