Attatch a bucket target location variable to an upload - fine-uploader

Forgive me for asking questions on behalf of my developer.
I need to define in the s3handler.php a variable called $targetbucket which is simply a amazon s3 bucket, not the one that is used to upload the files to but a subsequent bucket for user to encode video output into. This targetbucket is different for every user who uses the upload function and is used in a send email function inside the php file and includes relevant information pertaining to the next step in my process.
I am told the php file can't get this variable unless it's attached to the upload script. Ok- but this has to be a static script that I want for every user.
Therefore I need to define in my html a variable which is sent to the upload script and in turn to the php to use in the email function.
Is this at all possible? If not, what other method might I use please.

It's not clear why this variable needs to be passed from Fine Uploader. Regardless, you can pass any variable you like as a request parameter using Fine Uploader's setParams API method. For example, uploader.setParams({targetBucket: 'some-bucket'}) will include a matching parameter for all file upload requests.

Related

Uploading unique files at concurrent load using JMeter

We have usecase where we need to call an API that uploads its respective category of unique file.
For every API call we need to use a unique FileName. I mean File once used in an API call should not be used again.
For Example
CarAPI will be called by uploading a file-name from list of files (CarAP_1.xml to CarAP_1000.xml files)
File CarAP_1.xml once used in an API call should not be used again in next call
BikeAPI will be called by uploading a file-name from list of files (BikeAP_1.xml to BikeAP_1000.xml files)
File once used in an API call should not be used again.
Any thoughts or inputs on how we can achieve this using JMeter.
You can put these filenames
either to a CSV file and use HTTP Simple Table Server, its READ endpoint has KEEP=false mode so once the data is used it will be removed from memory hence you can avoid duplicate requests
or to Redis and use Redis Data Set Config which also provides possibility to remove the data from the list once it has been utilized
Both plugins can be installed using JMeter Plugins Manager

Can I serve files stored in Google Cloud Storage via a http.FileServer in golang?

I have developed a small web application that runs a web server in golang.
Each user can login, view the list of their docs (previously uploaded) and click on an item to view an html page that shows some fields of the document plus an tag with a src attribute
The src attribute includes an url like "mydocuments/download/123-456-789.pdf"
On the server side I handle the URL ("mydocuments/download/*") via an http Handler
mymux.HandleFunc(pat.Get("/mydocuments/download/:docname"), DocDownloadHandler)
where:
I check that the user has the rights to view the document in the url
Then I create a fileserver that obviously re-maps the url to the real path of the folder where the files are stored on the filesystem of the server
fileServer := http.StripPrefix("/mydocs/download/",http.FileServer(http.Dir("/the-real-path-to-documents-folder/user-specific-folder/)))
and of course I serve the files
fileServer.ServeHTTP(w, r)
IMPORTANT: the directory where the documents are stored is not the static-files directory I sue for the website but a directory where all files end after being uploaded by users.
My QUESTION
As I am trying to convert the code for it to work also on Google Cloud, I am trying to change the code so that files are stored in a bucket (or, better in "sub-directories" -as they do not properly exist- of a bucket).
How can I modify the code so to map the real document url as available via the cloud storage bucket?
Can I still use the http.FileServer technique above (if so what should I use instead of http.Dir to map the bucket "sub-folder" path where the documents are stored)?
I hope I was enough clear to explain my issue...
I apologise in advance for any unclear point...
Some options are:
Give the user direct access to the resource using a signed URL.
Write code to proxy the request to GCS.
Use http.FS with an fs.FS backed by GCS.
It's possible that a fs.FS for GCS already exists, but you may need to write one.
You can use http.FileSystem since it is an interface and can be implemented however you like.

Flash message require session

I'm trying to use express-flash in a standard web express js app. I don't want to use session, because I want to do the app as stateless as possible, but when I try to use without session, the app show me this error:
req.flash() requires sessions
Can I use express-flash without session? Can I use other alternatives for this kind of messages?
Thanks.
Note: A flash message is a variable stored within a session that is only available once, for the next request. That is if we put a flash variable and renders a page, the flash variable is available but if we render the same (or other) page again the flash variable is not present (it is destroyed).
-- acanimal
Based on this premise, you need to have sessions to use message flashing.
One way I think you can accomplish what you want is to add an item to the request (req) object in your middleware, and then in your controller, check if the key exists. You can then pass a specific message to your template, assuming you're using a template engine or pass it as part of your response.
Hope this helps.

How to detect the last Docpad render pass?

Im currently writing a small Docpad plugin to output a documents contentRenderedWithoutLayouts into a separate .json file next to the .html version for loading it via an ajax request later.
The plugin works by overriding Baseplugin's render: (opts) -> method and doing a few checks whether we're rendering a document and to html.
I now noticed that this method gets called multiple times for some documents, which seems to be render pass related. So how can I detect the final render pass per document to avoid writing the .json multiple times per render?
Many Thanks
--
Edit:
found the answer after another look at Docpads events list: http://docpad.org/docs/events
The writeAfter event is the right place to get the final data and have the output directory tree set up so I can put my .json files next to the .html.
In case you're interested find the plugin here: https://github.com/field/docpad-plugin-jsonfragment
Another approach to this would be to use the serverExtend event, and write a router that detects if it is an ajax request (existance of the IS_XHR header) and then sends the necessary json data from that. This would require your hosting platform to support node.js as you'll be using the docpad server.

Replacing the body of a proxied subrequest with the contents of a file

I'm using the upload module to write the uploaded file to disk as soon as it arrives in nginx. In addition, I'd like to create 2 subrequests:
POST to a URL containing the uploaded file
POST to another URL without the uploaded file
The second request is easy to do because the upload module has already stripped out the upload. My problem is with the first request: How do I get the uploaded file back into the the subrequest.
A solution for my question has been committed to the echo module.
The module you linked to has the upload_set_form_field directive and a few special variables (listed in that directive), which you can use to pass the file details to the backend as a POST variables. The example given appears to put the upload back in the POST data. Can you adapt your backend script to make that work?

Resources