Mise en place upload video presentation cote Symfony
This commit is contained in:
+2
-3
@@ -11,9 +11,8 @@ volume/www/website/.idea
|
||||
/volume/www/website/store/themes/talentstube-20170413/cache/*
|
||||
/volume/www/website/store/img/tmp/*
|
||||
volume/www/website/www/app/Resources/views/default/index.html.twig
|
||||
TODO
|
||||
|
||||
volume/www/website/www/.vscode/settings.json
|
||||
volume/www/website/www/app/config/jwt/private.pem
|
||||
volume/www/website/www/app/config/jwt/public.pem
|
||||
volume/www/website/www/app/config/jwt/private.pem
|
||||
volume/www/website/www/app/config/jwt/public.pem
|
||||
volume/www/website/www/web/sql/upload.pgsql
|
||||
|
||||
@@ -205,6 +205,52 @@ class AnswerController extends FOSRestController
|
||||
return new JsonResponse($status);
|
||||
}
|
||||
|
||||
// valid request (from postman code ):
|
||||
//POST /app_dev.php/api/media HTTP/1.1
|
||||
// Host: localhost
|
||||
// Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
|
||||
// Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE1NTg2MTM2NzYsImV4cCI6MTU1ODYxNzI3Niwicm9sZXMiOlsiUk9MRV9UQUxFTlQiLCJST0xFX1VTRVIiXSwidXNlcm5hbWUiOiJ0aG9tYXMuYmVycm9kQGUtZGVjbGljLmNvbSJ9.gREC7Haj2geQNn3WArAL4jhBcPI67YJuJOEYiTJ4VeJztM7TRKo8XplXXdDKRs-J_AsHIOmEYWb08AZIivNXw652Ge_9VhpvhS67xa2O30T-ZingVVofZ8Anjbgof32tVkwL2SzNd82rxw4DbFWgSE24h1tw2NO-EUnvLxD3eGUgPerdJ-g74zwJ4tv2kBI3_TaTR35x0HjPnxtihpT2FQHwR-kYQHtJb7rmR7XTloDBu-cZiiEkfgZekt2NyOvD58HcXy3hKZ09YvIFmwDnmVxOVvexVPPt8du-ozXqtt6IlXGslqTm_dX7eTNrg2uoKgliBV6AOYFFlylgIQU1-Wr6k_OCxDEscN3NkbTDVcQbE-xSE2wjFIO0Gilk-cpmW5Kx1VCtEtyscPRiYub6dXPBgObGdKGmTcYwlG3X03x9KO9oYmjVgIreZZg2WJTzwQOoU67QxhOYknPshBSm61-VaB9OwOGJG3M6FrhZR867-Rj64FEd0HWH9lMM5OO645hlDAe3lPCG6ffUBPBOjFWCGx8HPsv_PjOaMRf21UEFpVaTfAlHrKsUog5j8Qc5-OEz9vmmlog2KjWc67alEfJujnc0m3HV731IBirar5gaO360ebwUU6aSo6HSThOnwFrTxGiCd0Eqo5T5yW446HJBRhLFYiiJerJg6EbGlAM
|
||||
// User-Agent: PostmanRuntime/7.13.0
|
||||
// Accept: */*
|
||||
// Cache-Control: no-cache
|
||||
// Postman-Token: 49a92aa5-fa39-412c-bc23-9d6ae389fa1e,569d0fea-09ba-452f-9957-989fca193603
|
||||
// Host: localhost
|
||||
// accept-encoding: gzip, deflate
|
||||
// content-length: 228
|
||||
// Connection: keep-alive
|
||||
// cache-control: no-cache
|
||||
// Content-Disposition: form-data; name="upload"; filename="/C:/Users/Thomas/Pictures/Camera Roll/WIN_20180917_14_29_28_Pro.mp4
|
||||
// ------WebKitFormBoundary7MA4YWxkTrZu0gW--
|
||||
/**
|
||||
* @Rest\Post("/api/mediaPres", name="api_media_pres_upload")
|
||||
* @Rest\View(StatusCode = 201)
|
||||
*
|
||||
*/
|
||||
public function uploadPresAction(Request $request)
|
||||
{
|
||||
|
||||
$usr = $this->get('security.token_storage')->getToken()->getUser();
|
||||
$usr->getUsername();
|
||||
|
||||
$file = $request->files->get('upload');
|
||||
$status = array('status' => "success", "fileUploaded" => false);
|
||||
//dump($file);
|
||||
// If a file was uploaded
|
||||
if (!is_null($file)) {
|
||||
|
||||
$mediaManager = $this->get('media_manager');
|
||||
$message = $mediaManager->upload($usr, $file, $usr);
|
||||
//dump($message);
|
||||
// generate a random name for the file but keep the extension
|
||||
// $filename = uniqid().".".$file->getClientOriginalExtension();
|
||||
// $path = "/path/where/we/want-to-save-the-file";
|
||||
// $file->move($path,$filename); // move the file to a path
|
||||
$status = array('status' => "success", "fileUploaded" => true, "message" => $message);
|
||||
}
|
||||
|
||||
return new JsonResponse($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Rest\Post("/api/answers/message", name="api_answer_message")
|
||||
* @Rest\View(StatusCode = 201)
|
||||
|
||||
@@ -205,11 +205,7 @@ class Company
|
||||
private $countAds;
|
||||
|
||||
|
||||
/**
|
||||
* @var string $test
|
||||
* @ORM\Column(name="test", type="string", nullable=true)
|
||||
*/
|
||||
private $test;
|
||||
|
||||
|
||||
/***********************
|
||||
* Constructor
|
||||
@@ -940,27 +936,5 @@ class Company
|
||||
return count($this->getPublishedAds());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $test
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTest()
|
||||
{
|
||||
return $this->test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set $test
|
||||
*
|
||||
* @param string $test $test
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setTest(string $test)
|
||||
{
|
||||
$this->test = $test;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,9 +148,9 @@ class MediaManager
|
||||
$thumbnails = array();
|
||||
//PUSH VIDEO TO Vimeo
|
||||
if ($this->env == "dev") {
|
||||
$uriVimeo = "/videos/217844541";
|
||||
$uriVimeo = "/videos/385952221";
|
||||
$nameVimeo = "name";
|
||||
$linkVimeo = "/videos/217844541";
|
||||
$linkVimeo = "/videos/385952221";
|
||||
} else {
|
||||
$urlToPull = $this->mediaVideoUrl . $fileName;
|
||||
$response = $this->vimeo->request('/me/videos', array('type' => 'pull', 'link' => $urlToPull), 'POST');
|
||||
|
||||
Reference in New Issue
Block a user