Giter Site home page Giter Site logo

Comments (6)

frasmage avatar frasmage commented on May 22, 2024

Hi Nicholas,

What do you mean by update? Media is just an eloquent model, so you can
adjust any of its attributes manually, I.e. $media->mime_type = 'image/jpeg'; then call the save() method to update the records.

(On vacation so I might be slow to reply)

On Sep 1, 2016 4:19 PM, "Nicolas Binet" [email protected] wrote:

I'm trying to figure out a way to update a saved media.
Relations can be updated, but not the base file.
Am-I right ?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#18, or mute the thread
https://github.com/notifications/unsubscribe-auth/AA38rDxvACl4rk3pCDph0znCDRZ9aoDfks5qltD6gaJpZM4JyrmK
.

from laravel-mediable.

nicolasbinet avatar nicolasbinet commented on May 22, 2024

Let me know if I'm wrong, but I'm using MediaUploader::fromSource to upload and create a new Media.
But, there is no "updateFromSource" method to update an existing one.

from laravel-mediable.

frasmage avatar frasmage commented on May 22, 2024

Hi Nicolas,

What exactly has changed between the file on disk and the data stored in
the db record?

For the most part, the library considers media files to be constant once
uploaded, as this fits with the most common usage. That said, if you are
manipulating the file and you know what might change (e.g. size, mime,
etc.), you can update the fields manually, as described in the message
above.

You can also simply delete and reimport the media record.

Alternatively, the media:import command has a --force option, which
checks if any files in a directory no longer match their records and update
accordingly.

Finally, adding a proper MediaUploader::update() method is on my to-do
list for the next major or minor version. This would behave like
media:import --force for a single file at a time. Still in the works
though.

Hope this helps.

On Sep 3, 2016 12:56 PM, "Nicolas Binet" [email protected] wrote:

Let me know if I'm wrong, but I'm using MediaUploader::fromSource to
upload and create a new Media.
But, there is no "updateFromSource" method to update an existing one.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#18 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA38rNaDO92hkRe9o1Cz_9UGwq0yz_n5ks5qmVJagaJpZM4JyrmK
.

from laravel-mediable.

nicolasbinet avatar nicolasbinet commented on May 22, 2024

Hi frasmage,

Thanks for your extensive answer.

In my case, I'm trying to create a mediamanager the "wordpress way". Have a centralized repositories for medias, and associate them along the way to different models.
And sometimes I will, or one of my client will, want to re-upload a new version of a file, thus updating all it's uses.
In that case I don't want to delete the file, as it would break all relations.

I hope this clarifies my need.

Nicolas

from laravel-mediable.

frasmage avatar frasmage commented on May 22, 2024

Hi Nicolas,

OK, I see what you mean. The MediaUploader class wouldn't be able to do
that out of the box (though the update feature I'm working on would help).

In the meantime, you could use the uploader to place the file in a temp
location (for validation, media generation, etc.), then manually swap the
two files on disk and update the original record with the attributes of the
new one.

On Sep 7, 2016 7:42 AM, "Nicolas Binet" [email protected] wrote:

Hi frasmage,

Thanks for your extensive answer.

In my case, I'm trying to create a mediamanager the "wordpress way". Have
a centralized repositories for medias, and associate them along the way to
different models.
And sometimes I will, or one of my client will, want to re-upload a new
version of a file, thus updating all it's uses.
In that case I don't want to delete the file, as it would break all
relations.

I hope this clarifies my need.

Nicolas


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#18 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA38rGuqAEY50n-Av849m8GGpN3iSFPlks5qnk7DgaJpZM4JyrmK
.

from laravel-mediable.

frasmage avatar frasmage commented on May 22, 2024

Hi @nicolasbinet, this is now implemented in version 2.0, see the docs for instructions on this feature.

from laravel-mediable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.