Rails 7 Active Storage - how do I upload/add image(s) to list of existing images without overriding/purging existing images? - rails-activestorage

I have got a Listing model to which I upload multiple images. I just can't figure out how to upload additional images to each Listing without purging/replacing existing images.
Here's the scenario: I upload one or more images, upon editing the files, when I attempt to upload new images, the existing ones are simply replaced by the new one(s). How do I keep both the existing and the new ones?
I have successfully added a check to delete feature in my update method (see below), and all I need is to be able to add newly uploaded images to whatever is left of the existing images.
Class Listing
has_many_attachments :photos
Listing Controller
def update
if params[:listing][:photo_ids]
params[:listing][:photo_ids].each do |photo_id|
photo = listing.photos.find(photo_id)
photo.purge
end
end

The solution on Rail 6 is to add the following line to configuration in config/application.rb
config.active_storage.replace_on_assign_to_many = false
source: Details here

Related

Is Shopware 6 Uploaded Media Stored In The Database?

Where exactly are the (product) image files stored? I can't find the images in my Shopware 6 installation folders. If it is in the database, explain how it is done and which table because I have looked at the media table and can't seem to decode where the image file is.
As #zabus wrote, this is dependent on the CDN strategy.
Those strategies are implemented in https://github.com/shopware/platform/tree/trunk/src/Core/Content/Media/Pathname/PathnameStrategy, in case you want to know in detail how a path is generated, which happens on-the-fly.
There is a WIP pull request to store the final path in the database.
Public files are saved in public/media, while private files are in files/media.
the env variable SHOPWARE_CDN_STRATEGY_DEFAULT defines how the files are saved.
For example:
SHOPWARE_CDN_STRATEGY_DEFAULT=id

Kentico 10 : How to find the file uploaded by DirectUploadControl

We are using Kentico 10
Question 1
We are using DirectUploadControl to upload image in a page form.
We have column PDFImage in the page type. I can see the value of this field to be a GUID.
Where the image is stored on disk when uploaded by this control? Which table is updated with file name?
I tried the page type table, cms document and media file but couldn't find.
Question 2
We need to process the image when uploaded. Is there an event? Right now we are doing this in DocumentEvents.SaveVersion.After
This depends on how the system is set to store files. So, it can be in the DB or on disk or both. When on disk, it depends what folder is set to store the attachments.
In the document events there is the SaveAttachment event - so maybe you can try using that one. Or, it might be better to create a custom uploader form control - depending on your needs.

Azure Search - Highlights - Locating in image

Just looking for guidance or even a general outline on approach here.
I am using azure search to OCR a batch of pdfs. I have turned on hit highlighting and I am successfully getting results back there that I am looping through / displaying in my view for the end user. I was looking on expanding that functionality to show the pdf images with the highlighting on the images themselves like in the JFK azure example. I am not proficient in react and seem to be getting lost there.
I am assuming I need to save off the OCR images to a data store for reference using the normalized_images that are created? I do have pdfs locally I can load but assume the OCR images maybe different. Have turned on GeneratedNormalizedImagesPerPage and turned on cache which creates files in my storage account.
Then I assume I need to pull the associated image, display it, use the highlight results and pull a corresponding bounding box where the phrase was detected? Problem with that approach is that I do not see any association between the highlight hit and the location (bounding box) of the hit nor the associated image file the hit was on.
Probably way off on approach here but any guidance is appreciated.
Edit 1
I did noticed the items on this page in the JFK example: https://github.com/microsoft/AzureSearch_JFK_Files/tree/master/JfkWebApiSkills/JfkWebApiSkills
Would trying to replicate the ImageStore (so those are stored in my storage account) and then the HocrGenerator (appears to handle points in a doc) into my skillset for my index be the approach?
There are a few steps here:
you need to save the layoutText from the OCR skill somewhere the UI can access it. The JFK Files demo converts it to a HOCR (to display in the UI) and saves it in index as a field in the index so that it is retrieved in the search results. HOCR isn't necessary and you may find it more efficient to store the layout in blobs using a knowlege store object projection.
save the extracted images into blob storage using a file projection into the knowledge store. Keep in mind that the images may be resized in the process and the coordinates will match the resized image saved to the store. If you want to map the coordinates to the original image see this.
At search time, map the highlight to the the metadata. You will find this code in the nodejs frontend, however it may be simpler to follow in the original demo by following the code here. Essentially you just find the first occurrence of the highlighted word in the metadata, display the associated image, and calculate the bounding region of the word.

Why do Domino store all my inline images in the xsppers folder?

Every time I reload my webpage new files are added to the c:\windows\temp\notes...\xsppers folder on the server. and these files are never deleted, I have to manually delete them, and it can be several GB of data to delete every month
I have a simple xpage with a repeat control that display data from several documents using a computed Field mapped to a rich text field.
the richtext fields contain a lot of inline images that has been added using the notes client.
Now, every time I reload my webpage these images are now detached to the xspper folder and is causing my harddrive to run out of disc space all the time.
What is the reason for this behaviour and how can I avoid it from happening?
In the image below you see all the gifs that has been created with a new uinque name, each time I reload my webpage a new set up images are added to the folder.
I am using Domino 9
As Egor Margineanu wrote, this can happen if your images are not stored as MIME images in your Rich Text item.
This forces the domino server to detach the attachment(s) over and over again to disc, because it is required to generate a GIF form the inline image. If you change the MIME type of your rich text item in your form and save the document(s) again, the images are stored in the "correct" format, and the domino server is able to identify that the images are already on the HDD.
As far I can see the temorarly detached attachments are not wiped when the session ends. This seems to happen if the application ends.
Not a complete answer but some clarification from the XPages Portable Command Guide, page 36:
The files remain in the temporary persistence location until the user
session expires. The file is not removed after the document is saved,
although it is no longer referenced by URLs.
It may be useful to change this
setting to point to a different location if the folder is taking up
too much space on the main server drive and another drive has more
available space. This option is server-wide, so it should be set in
the server xsp.properties file. Values set in a particular
application’s xsp.properties file are ignored.
Based on your question, Thomas, it seems that this is not what you are experiencing.

expressionengine image not deleted from server after entry is deleted

I have a SafeCracker File for as a fieldtype for my channel entries. Everything works fine and i'm able to upload images along with the entry. In EE control panel, if i edit the entry and delete the image or even if i delete the whole entry, the images associated with this entry is are not deleted from the server. Why is this happening. is this a known issue.
This isn't a bug; it's how ExpressionEngine handles file assets. When you delete an image from an entry, EE deletes the relationship between the image and the entry. The image will continue to exist on the server until you delete the image itself. To do this, navigate to EE's file manager and delete the image there.
The reason EE behaves this way is because it allows you to easily link to an image or file from multiple entries in the system. If you had multiple entries linking to an image and were able to delete it from one of those entries, you would break the relationship to it from all of the other pages that referenced it.

Resources