Recherche avancée

Médias (91)

Autres articles (53)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

  • Use, discuss, criticize

    13 avril 2011, par

    Talk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
    The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
    A discussion list is available for all exchanges between users.

  • MediaSPIP en mode privé (Intranet)

    17 septembre 2013, par

    À partir de la version 0.3, un canal de MediaSPIP peut devenir privé, bloqué à toute personne non identifiée grâce au plugin "Intranet/extranet".
    Le plugin Intranet/extranet, lorsqu’il est activé, permet de bloquer l’accès au canal à tout visiteur non identifié, l’empêchant d’accéder au contenu en le redirigeant systématiquement vers le formulaire d’identification.
    Ce système peut être particulièrement utile pour certaines utilisations comme : Atelier de travail avec des enfants dont le contenu ne doit pas (...)

Sur d’autres sites (5220)

  • Why does File upload for moving image and Audio to tmp PHP folder work on Windows but only image upload portion works on Mac using MAMP ?

    31 mai 2021, par Yazdan

    So according to my colleague who tested this on Windows says it works perfectly fine , but in my case when I use it on a Mac with MAMP for Moodle , the image files get uploaded to the correct destination folder without an issue whereas the audio files don't move from the tmp folder to the actual destination folder and to check if this was the case ... I just changed and gave a fixed path instead of $fileTmpLoc and the file made it to the correct destination. Sorry I know the first half of the code isn't the main issue but I still wanted to post the whole code so one could understand it easily, moreover I am just beginning to code so please "have a bit of patience with me" . Thanks in advance

    


    &#xA;// this file contains upload function &#xA;// checks if the file exists in server&#xA;include("../db/database.php");&#xA;require_once(dirname(__FILE__) . &#x27;/../../../config.php&#x27;);&#xA;global $IP;&#xA;&#xA;$ajaxdata = $_POST[&#x27;mediaUpload&#x27;];&#xA;&#xA;$FILENAME = $ajaxdata[1];&#xA;$IMAGE=$ajaxdata[0];&#xA;// an array to check which category the media belongs too&#xA;$animal= array("bird","cat","dog","horse","sheep","cow","elephant","bear","giraffe","zebra");&#xA;$allowedExts = array("mp3","wav");&#xA;$temp = explode(".", $_FILES["audio"]["name"]);&#xA;$extension = end($temp);&#xA;&#xA;&#xA;&#xA;$test = $_FILES["audio"]["type"]; &#xA;&#xA;&#xA;if (&#xA;   $_FILES["audio"]["type"] == "audio/wav"||&#xA;   $_FILES["audio"]["type"] == "audio/mp3"||&#xA;   $_FILES["audio"]["type"] == "audio/mpeg"&#xA;   &amp;&amp;&#xA;   in_array($extension, $allowedExts)&#xA;   )&#xA;   {&#xA;&#xA;       // if the name detected by object detection is present in the animal array&#xA;       // then initialize target path to animal database or to others&#xA;       if (in_array($FILENAME, $animal)) &#xA;       { &#xA;           $image_target_dir = "image_dir/";&#xA;           $audio_target_dir = "audio_dir/";&#xA;       } &#xA;       else&#xA;       { &#xA;           $image_target_dir = "other_image_dir/";&#xA;           $audio_target_dir = "other_audio_dir/";&#xA;       } &#xA;       // Get file path&#xA;       &#xA;       $img = $IMAGE;&#xA;       // decode base64 image&#xA;       $img = str_replace(&#x27;data:image/png;base64,&#x27;, &#x27;&#x27;, $img);&#xA;       $img = str_replace(&#x27; &#x27;, &#x27;&#x2B;&#x27;, $img);&#xA;       $image_data = base64_decode($img);&#xA;&#xA;       //$extension  = pathinfo( $_FILES["fileUpload"]["name"], PATHINFO_EXTENSION ); // jpg&#xA;       $image_extension = "png";&#xA;       $image_target_file =$image_target_dir . basename($FILENAME . "." . $image_extension);&#xA;       $image_file_upload = "http://localhost:8888/moodle310/blocks/testblock/classes/".$image_target_file;&#xA;       &#xA;       &#xA;       $audio_extension ="mp3";&#xA;       $audio_target_file= $audio_target_dir . basename($FILENAME. "." . $audio_extension) ;&#xA;       $audio_file_upload = "http://localhost:8888/moodle310/blocks/testblock/classes/".$audio_target_file;&#xA;&#xA;       // file size limit&#xA;       if(($_FILES["audio"]["size"])&lt;=51242880)&#xA;       {&#xA;&#xA;           $fileName = $_FILES["audio"]["name"]; // The file name&#xA;           $fileTmpLoc = $_FILES["audio"]["tmp_name"]; // File in the PHP tmp folder&#xA;           $fileType = $_FILES["audio"]["type"]; // The type of file it is&#xA;           $fileSize = $_FILES["audio"]["size"]; // File size in bytes&#xA;           $fileErrorMsg = $_FILES["audio"]["error"]; // 0 for false... and 1 for true&#xA;           &#xA;           if (in_array($FILENAME, $animal)) &#xA;           { &#xA;               $sql = "INSERT INTO mdl_media_animal (animal_image_path,animal_name,animal_audio_path) VALUES (&#x27;$image_file_upload&#x27;,&#x27;$FILENAME&#x27;,&#x27;$audio_file_upload&#x27;)";&#xA;           } else {&#xA;               $sql = "INSERT INTO mdl_media_others (others_image_path,others_name,others_audio_path) VALUES (&#x27;$image_file_upload&#x27;,&#x27;$FILENAME&#x27;,&#x27;$audio_file_upload&#x27;)";&#xA;           }&#xA;&#xA;           // if file exists&#xA;           if (file_exists($audio_target_file) || file_exists($image_target_file)) {&#xA;               echo "alert";&#xA;           } else {&#xA;               // write image file&#xA;               if (file_put_contents($image_target_file, $image_data) ) {&#xA;                   // ffmpeg to write audio file&#xA;                   $output = shell_exec("ffmpeg -i $fileTmpLoc -ab 160k -ac 2 -ar 44100 -vn $audio_target_file");&#xA;                   echo $output;&#xA;               &#xA;                   // $stmt = $conn->prepare($sql);&#xA;                   $db = mysqli_connect("localhost", "root", "root", "moodle310"); &#xA;                   // echo $sql;&#xA;                   if (!$db) {&#xA;                       echo "nodb";&#xA;                       die("Connection failed: " . mysqli_connect_error());&#xA;                   }&#xA;                   // echo"sucess";&#xA;                   if(mysqli_query($db, $sql)){&#xA;                   // if($stmt->execute()){&#xA;                       echo $fileTmpLoc;&#xA;                       echo "sucess";  &#xA;                       echo $output;&#xA;                   }&#xA;                   else {&#xA;                       // echo "Error: " . $sql . "<br />" . mysqli_error($conn);&#xA;                       echo "failed";&#xA;                   }&#xA;&#xA;               }else {&#xA;                   echo "failed";&#xA;               }&#xA;&#xA;               &#xA;           &#xA;           &#xA;           }&#xA;   &#xA;    // $test = "ffmpeg -i $outputfile -ab 160k -ac 2 -ar 44100 -vn bub.wav";&#xA;       } else&#xA;       {&#xA;         echo "File size exceeds 5 MB! Please try again!";&#xA;       }&#xA;}&#xA;else&#xA;{&#xA;   echo "PHP! Not a video! ";//.$extension." ".$_FILES["uploadimage"]["type"];&#xA;   }&#xA;&#xA;?>&#xA;

    &#xA;

    I am a student learning frontend but a project of mine requires a fair bit of backend. So forgive me if my question sounds silly.

    &#xA;

    What I meant by manually overriding it was creating another folder and a index.php file with echo "hello"; $output = shell_exec("ffmpeg -i Elephant.mp3 -ab 160k -ac 2 -ar 44100 -vn bub.mp3"); echo $output; so only yes in this case Elephant.mp3 was changed as the initial tmp path so in this case as suggested by Mr.CBroe the permissons shouldn't be an issue.

    &#xA;

    Okay I checked my Apache_error.logonly to find out ffmpeg is indeed the culprit ... I had installed ffmpeg globally so I am not sure if it is an access problem but here is a snippet of the log

    &#xA;

    I checked my php logs and found out that FFmpeg is the culprit.&#xA;Attached is a short log file

    &#xA;

    [Mon May 31 18:11:33 2021] [notice] caught SIGTERM, shutting down&#xA;[Mon May 31 18:11:40 2021] [notice] Digest: generating secret for digest authentication ...&#xA;[Mon May 31 18:11:40 2021] [notice] Digest: done&#xA;[Mon May 31 18:11:40 2021] [notice] Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/1.0.2o PHP/7.2.10 configured -- resuming normal operations&#xA;sh: ffmpeg: command not found&#xA;sh: ffmpeg: command not found&#xA;sh: ffmpeg: command not found&#xA;

    &#xA;

  • Revision 6723e34224 : Merge "fix permissions on cpplint.py (0644->0755)" into experimental

    4 mai 2013, par James Zern

    Merge "fix permissions on cpplint.py (0644->0755)" into experimental

  • "File doesn't exist" - streamio FFMPEG on screenshot after create method

    3 mai 2013, par dodgerogers747

    I have videos being directly uploaded to S3 using Amazon's CORS configuration. Videos are uploaded via a dedicated S3 form, once they have been uploaded successfully the URL of the video is appended to the @video.file hidden_field via javascript and then the video saves.

    I can't get this after_save method to work which takes a screenshot of the video and saves it to S3 via carrierwave after the video has been saved as a rails object. ( It was previously working using a carrierwave video upload instance )

    It errors out withErrno::ENOENT - No such file or directory - the file &#39;http://bucket-name.s3.amazonaws.com/uploads/video/file/secure-random-hex/video_name.m4v&#39; does not exist: I have tried running this method as a class method to call it from the console but it always comes back with the same error, even though the video exists.

    My bucket is set to public, read and write. How come it doesn't think the file exists ?

    If anyone needs more code just shout, thanks in advance.

    application trace

    Started POST "/videos" for 127.0.0.1 at 2013-05-03 10:48:07 -0700
    Processing by VideosController#create as JS
     Parameters: {"utf8"=>"✓", "authenticity_token"=>"MAHxrVcmPDtVIMfDWZBwL0YnzaAaAe1PTGip5M4OVoY=", "video"=>{"user_id"=>"5", "file"=>"http://bucket-name.s3.amazonaws.com/uploads/video/file/secure-random-hex/video.m4v"}}
     User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 5 LIMIT 1
      (0.1ms)  BEGIN
     SQL (20.5ms)  INSERT INTO `videos` (`created_at`, `file`, `question_id`, `screenshot`, `updated_at`, `user_id`) VALUES (&#39;2013-05-03 17:48:07&#39;, &#39;http://teebox-network.s3.amazonaws.com/uploads/video/file/secure-random-hex/video.m4v&#39;, NULL, NULL, &#39;2013-05-03 17:48:07&#39;, 5)
      (44.0ms)  ROLLBACK
    Completed 500 Internal Server Error in 71ms

    Errno::ENOENT - No such file or directory - the file &#39;http://teebox-network.s3.amazonaws.com/uploads/video/file/secure-random-hex/video.m4v&#39; does not exist:
     (gem) streamio-ffmpeg-0.9.0/lib/ffmpeg/movie.rb:10:in `initialize&#39;
     app/models/video.rb:25:in `new&#39;
     app/models/video.rb:25:in `take_screenshot&#39;

    video.rb

     attr_accessible :user_id, :question_id, :file, :screenshot
     belongs_to :question
     belongs_to :user

     default_scope order(&#39;created_at DESC&#39;)

     after_create :take_screenshot

     mount_uploader :screenshot, ImageUploader

     validates_presence_of :user_id, :file

     def take_screenshot
       FFMPEG.ffmpeg_binary = &#39;/opt/local/bin/ffmpeg&#39;
       movie = FFMPEG::Movie.new("#{self.file}")
       self.screenshot = movie.screenshot("#{Rails.root}/public/uploads/tmp/screenshots/#{File.basename(self.file)}.jpg", seek_time: 2 )
       self.save!
     end

    videos/_form.html.erb

    <form action="http://bucket-name.s3.amazonaws.com" data-remote="true" class="direct-upload" enctype="multipart/form-data" method="post">
     <input type="hidden" />
     <input type="hidden" value="ACCESS_KEY" />
     <input type="hidden" value="public-read" />
     <input type="hidden" />
     <input type="hidden" />
     <input type="hidden" value="201" />
     <input type="file" />
    </form>

    &lt;%= form_for @video, html: { multipart: true, id: "new_video" }, remote: true do |f| %>
           &lt;% if @video.errors.any? %>
       <div>
       <h2>&lt;%= pluralize(@video.errors.count, "error") %> prohibited this post from being saved:</h2>

     <ul>
       &lt;% @video.errors.full_messages.each do |msg| %>
           <li>&lt;%= msg %></li>
           &lt;% end %>
       </ul>
       </div>
    &lt;% end %>

       &lt;%= f.hidden_field :user_id, value: current_user.id %>
       &lt;%= f.hidden_field :file %><br />

       &lt;% end %>

    ImageUploader

    class ImageUploader &lt; CarrierWave::Uploader::Base

     include CarrierWave::RMagick

      include Sprockets::Helpers::RailsHelper
      include Sprockets::Helpers::IsolatedHelper

     storage :fog

     before :store, :remember_cache_id
     after :store, :delete_tmp_dir

       def cache_dir
         Rails.root.join(&#39;public/uploads/tmp/&#39;)
       end

       def remember_cache_id(new_file)
         @cache_id_was = cache_id
       end

       def delete_tmp_dir(new_file)
         if @cache_id_was.present? &amp;&amp; @cache_id_was =~ /\A[\d]{8}\-[\d]{4}\-[\d]+\-[\d]{4}\z/
           FileUtils.rm_rf(File.join(root, cache_dir, @cache_id_was))
         end
       end

     process resize_and_pad: [306, 150, &#39;#000&#39;]

     def store_dir
       "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
     end

     def extension_white_list
       %w(jpg)
       # %w(ogg ogv 3gp mp4 m4v webm mov)
     end