web development – Run Python Script on Uploaded File

I would like to have a website whose entire page consists of:

  1. accepting a file as drop & drop upload;
  2. run my Python script on that file in the background;
  3. make the output file of the script available for download.

(Check the mockup below)

As a hardware developer I have no idea whatsoever what keywords to use to ask a Fiverr Developer for advice. Since anything “web” is complete black magic.

Can someone point me in the right direction?

8 – Adding attributes to a link to an uploaded file

I have been asked to add target=”_blank” to the links that are produced when a user uploads a file on a Drupal 8 site.

The field type is “File”. Multiple uploads are allowed.

Twig debug shows me that the field is being produced by the core template “file-link.html.twig”. The entire uncommented contents of that template are:

<span{{ attributes }}>{{ link }}</span>
{% if file_size %}
  {# @todo remove class before Drupal 9.0.0 #}
  <span class="file-size">({{ file_size }})</span>
{% endif %}

I brought that template into my custom theme and tried to add the attribute to the link. I thought I’d be editing the {{ link }} part of the template, changing it to attach attributes. I did variations of this:

{{ link(item.title, item.url, attributes.setAttribute(‘target’,’_blank’)) }}

Every syntax I tried produced a fatal PHP error. Thinking I was doing the attribute syntax wrong, I tested by simply trying to add a single class.

{{ link(item.title, item.url, { 'class': ('bananas') }) }}

That was still a white screen of death, so I guess I can’t use that syntax on the {{ link }} field in my file-link template.

I’ve been googling my eyeballs out of my head. I found this cool idea:

{% for item in items %}
  {{ item.content|merge({'#attributes': {'class': ('button', 'button--arrow', 'button--centered')}}) }}
{% endfor %}

so I adapted it for my field.html.twig template like so, changing this part:

{% for item in items %}
    <div{{ item.attributes }}>{{ item.content }}</div>
{% endfor %}

to this:

{% for item in items %}
      <div{{ item.attributes }}>{{ item.content|merge({'#attributes': {'target': ('_blank')}}) }}</div>
{% endfor %}

And while at least the page loaded and didn’t have a fatal error, the target attribute did not appear on the link.

Does anyone have any advice for me getting an attribute onto a file upload link? Almost everything I’ve found has to do with the link field, not the file upload field. Thanks for your time.

8 – How can I create an alias to point to an uploaded file?

I agree with Clive and base oh his comment, to redirect all files to another route you can use .htaccess route direction. So,

first solution:
add to following line in your .htaccess file.

RewriteRule ^sites/default/files/(.*)$ /files/$1 (L,NC)

note: you can use whatever you want instead of files, like assets etc.

PS: if your files are Media types, with pathauto module you can create a pattern to redirect them additionally you can let the user override them the what path he wants.

second solution:
install https://www.drupal.org/project/file_entity module and then with pathauto module you can create an alias for files. like files/file-title.

third-solution: use https://www.drupal.org/project/path_file module

The Path File module allows content editors to upload files and
specify the url at which they will be available. Normally, when
uploading a file to Drupal with the same name as an existing file, it
is given a new name instead of overwriting the existing file. This can
problematic when file urls are referenced in content, menus, etc but
may need to be updated in the future. The Path File module allows you
to mitigate the impact of those changes by setting up a canonical url
alias which will always point to the most up-to-date file

attachments – How do I set the browser icon on a PDF uploaded to Media Library?

I have uploaded PDF files to my site to allow visitors to view those PDFS.

When the visitor clicks on the link and the PDF is displayed, the icon in the browser tab changes to the WordPress logo.

Eg.

 https://example.com/wp-content/uploads/my_file.pdf

Show this header:

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>my file.pdf</title>
<!-- This snippet is used in the Firefox extension (included from viewer.html) -->
<base href="resource://pdf.js/web/">
 <script src="../build/pdf.js"></script>
<link rel="stylesheet" href="viewer.css">
  <script src="viewer.js"></script>
 </head>

How do I modify the ‘head’ tag to display my own site icon?

Users need to select from generated / uploaded files — however some folders/files are ineligible for selection

A major part of our product is the data room. Users generate and upload up to hundreds of documents. In various workflows that require company approvals, they can pick from documents in the data room rather than uploading a document.

However only certain documents in their data room should be selectable. For example if the workflow asks for a Board Approval, the user should only be able to select from board approvals or from one of the documents they uploaded (because we don’t know what they are). So most of the documents and folders in their data room shouldn’t be selectable.

Right now we show a filtered list of documents and folders – however recently we’ve gotten feedback that users are confused when they don’t see documents they know they uploaded/generated.

How do we highlight what is applicable, reassure users that the file structure/everything is still there, but also avoid clogging up the selection with non-applicable files?

If I delete from my drive – will it delete on another person’s drive that I’ve uploaded to?

Sorry if this is a bit convoluted. My client has shared all their Google Drive folders with me. I do the work, and then upload into the respective folders. For some reason – the work I’ve done ends up on my drive too. No clue why. (If anyone can answer that, that’ll be a bonus!)

If I delete the work from my drive, to free up space – will they delete on my client’s side too?

Magento 2 how to read the uploaded csv from front end form

Here am trying to read the csv file which is uploaded by frontend form.
but am not able to open or read the file content.
here is form file code.

<form class="import-shipping-form" action="http://website.co/zone_customer/Index/UploadCsv" method="POST" >
  <?php echo $block->getBlockHtml('formkey'); ?>
    <input type="file" required class="required-entry" name="my_custom_file" id="my_custom_file" />
    <button type="submit">Import</button>
</form>

This is the controller

app/code/Zone/Customer/Controller/Index/UploadCsv.php

<?php
namespace ZoneControllerIndex;

class UploadCsv extends MagentoFrameworkAppActionAction
{
    protected $resultPageFactory;
    protected $jsonHelper;
    protected $_fileUploaderFactory;
    protected $csvProcessor;
public function __construct(
        MagentoFrameworkFileCsv $csvProcessor,
        MagentoMediaStorageModelFileUploaderFactory $fileUploaderFactory,
        MagentoFrameworkAppActionContext $context,
        MagentoFrameworkViewResultPageFactory $resultPageFactory,
        MagentoFrameworkJsonHelperData $jsonHelper
    ) {
        $this->csvProcessor = $csvProcessor;
        $this->_fileUploaderFactory = $fileUploaderFactory;
        $this->resultPageFactory = $resultPageFactory;
        $this->jsonHelper = $jsonHelper;
        parent::__construct($context);
    }
     public function execute()
    {
       $data = $this->getRequest()->getPostValue();
       try{
            if(isset($data('my_custom_file')('0'))) {
            $importProductRawData = $this->csvProcessor->getData($data('my_custom_file'));
             foreach ($importProductRawData as $rowIndex => $dataRow) {
                 print_r($dataRow);
             }
          } catch (Exception $e) {
            $this->messageManager->addError($e->getMessage());
         }
    }
}

Where am doing wrong. Can I get Help? Thank you in advance.

Bitvise SFTP on upload command – pass uploaded file name as argument to a batch file

I am using the on upload command option in Bitvise SFTP to run a batch script
Is there a way i can pass the file name of the uploaded file to the batch script as an argument?

media – Get all uploaded images using REST api

I need to get all the images that are uploaded in my wordpress installation using the REST API.
I’ve tried using the wp-json/wp/v2/media endpoint but it will give me only the last 10 images uploaded that are attached to the last published post but this isn’t what I was expectinng.

How I can get all the images that are uploaded in wordpress unsing the rest api?

ios – Are Firebase Analytics events uploaded after opt out?

Using Firebase Analytics on iOS with swift I wonder how firebase handles the following case:

The app has per default firebase analytics enabled to track the install event. After that, which is immediately after app started, I want to disable firebase analytics. Considering that the event has been tracked, this event is batched first for some time before it gets uploaded. The question is, will this event be uploaded despite the fact that firebase analytics is now disabled, because this event has been tracked before the framework has been disabled?