Is it possible to check for the presence of a specific directory structure and create it if it doesnt exist?
I'm creating a blob like so:
When the directory doesn't exist, I am getting:
How do we create the directory structure when it doesnt exist?
Firstly Azure Blob doesn't support folder, it's a simulate directory. You may specify a character or string delimiter within a blob name to create a virtual hierarchy (e.g., the forward slash /). You could refer to this link.
So you don't need to check for the presence of a specific directory, just name the blob with directory then it will create the folder and the blobs with same directory prefix will be classified in a same folder.
Just name the blob with directory prefix like this foldername/blobname.
As far as I know, there isn't an action in logic app to create a container. So I think you can add a function in your logic app to create the container, then create the blob. I post the screenshot below:
Create azure function(here I use v1 runtime version)
Then add this function to your logic app and provide the request body
Create the blob and fill in the "Specify folder path to upload" box with /azure because the request body above is "name":"azure".
Run this logic app, it will create a container named "azure" and create the blob named "testblob".
Related
I have written an application in CakePHP 3.x and there is a form to upload files.
At present, files are being uploaded to WWW_ROOT.'files' which is /app/webroot/files/ path.
To store files separately from core application, I created a subdomain cdn.example.com whose path is like /home/user/example.com/cdn.example.com/.
since, uploading files requires absolute path, how can I get absolute path of the subdomain cdn.example.com same as $_SERVER['DOCUMENT_ROOT']; from example.com?
First check if your server allow to write files from main domain to subdomain.
You can't get the absolute path of a different domain of the one you deployed your application, you should store the path in a variable or in constant.
If you really need to store files in another domain/subdomain and any path is blocked you should consider to reupload the files via FTP script.
I created a pass statically by typing command line in order to create pass.pkpass. I also use web service in MAMP. How to generate a pass dynamically ? and where is pass.pkpass stored ?
To generate the pass dynamically, you will need code that will:
Retrieve all the dynamic data that you want to put into the pass
Create a pass.json file containing the dynamic pass data and compute its SHA1 hash
Gather the pass assets (images, locale strings, etc.) and compute their SHA1 hash
Assemble the manifest file (list of files in the .pkpass bundle and their SHA1 hashes)
Sign the manifest file with your PassID Certificate and include the Apple WWDR cert
Zip all of the assets up into a .pkpass bundle
Serve the .pkpass bundle with the correct MIME type
Cleanup any temporary folders/files you use in the above process
You may also need code to:
Generate random tokens for the serialNumber and authenticationToken
Record the pass details in a database
As for where the .pkpass files go, this is entirely up to you. You can either store them or delete them once they have been served to the device. Since the code that you will need can recreate the .pkpass bundle, and since your web service will send a 304 response to a device that already has the latest version of the pass, there is little value in keeping these files on your server.
If you are using MAMP, then this PHP Library is a good place to start.
Is there a way to restrict content download "Restricting Anonymous Users From Downloading Files"
Right now, once the user is logged in and he is able to obtain the URL to a path, he can re-download it again even if he logs off.
We've tried
-Rules Module and Content_Access Module to no avail.
it only supports:
Basic Rules per node
There's no
Basic Rules per Content (i.e. videos)
You can control access to files via Drupal only if both conditions are met:
private mode is on (see /admin/config/media/file-system)
Download folder is outside web server access, i.e. file upload folder contents are not accessible from the web.
See hook hook_file_download() which is called for every private file.
Control access to private file downloads and specify HTTP headers.
This hook allows modules enforce permissions on file downloads when the private file download method is selected. Modules can also provide headers to specify information like the file's name or MIME type.
I copied DB/PDO/MySQL.php from the crud example and put that directory structure in one of my API directories (and made changes for use with my database).
The API structure is myapi/artists (so the db stuff is myapi/artists/DB/PDO/MySQL.php) and I have index.php and Artists.php with the Artists API class.
so now I call $this->dp = new DB_PDO_MySQL(); in the Artists class and that works.
But I'd like to be able to use some common db functions across multiple API classes and have been unable to get the db stuff to work unless it is inside each API directory.
I tried putting myapi/DB/PDO/mysql.php under the vendor directory and edited AutoLoader.php to add an alias for 'myapi\DB\PDO' but that didn't work.
So, the question is, how do I configure things so I can share some common db code?
Assume I will have multiple API subdirectories under myapi directory (and myapi is at the same level as the examples directory).
Keep the MySQL.php file in vendor/DB/PDO folder. Then you dont have to edit AutoLoader.php
I'm looking for a CakePHP best practice to serve folders/files to clients after they are authentificated. I know it's simpler to use a .htpasswd/.htaccess based solution but i wonder for a better way.
What is it for?
I want to create a client-area where authenticated clients can see contents of there private folder(s). E.g. to test some static html templates before CMS Integration or upload some documents like commented screenshots or pdf files.
A usecase could be:
Create a new client (only by admin)
Generate Login credentials for different user of the same client
Create a new client folder (only by admin)
Upload some static html to the client folder
After login the client can access the folder and view the html
After logout access to the static files is restricted
Any suggestions?
Do you know about CakePHP's "Media Views"? I think that you might be able to do what you want with them.
quick & dirty example...
public function serve($filename = null) {
if($filename && $this->Auth->user()) {
$this->viewClass = 'Media';
$params = array(
'id' => $filename, // full filename
'name' => 'example',
'download' => FALSE, // true, then you get a download box
'extension' => get_the_file_extension($filename),
'path' => APP . 'outside_webroot_dir' . DS
);
$this->set($params);
} else {
// redirect to login or something
}
}
I think the easiest way is to use a database structure for this.
The files are stored on the server anyway, where does not matter.
This is how you do:
Create a table in the database called DataFile (due "File" causes problems with the Cake "File" class). Fields should be something like: id, data_folder_id, name, size, mime_type etc. Use what fits your needs.
Create a table in the database call DataFileFolder. Fields here: id, parent_id, name, visible. Same as above, whatever fits your needs.
Create an association key in the client table or a whole assocation table if needed. (For example: one client and 50 folders in different places). Be aware of the assocation you create. If you use Client->DataFolder the client has automatically access to all files within that folder.
Bake models and a FileController with an index frontend method and admin actions as well as views.
Optimize admin methods for creating either a file or a folder record.
The index method for the frontend has one parameter which represents the folder id. You output each an every folder and file in the folder starting with the first the user is allowed to access. You could also just ouput a list of folders the user is allowed to access in case these folders are on different levels of the new "file manager". You have to check permission on each an every new page call for the given folder id. But that's clear, i think.
Implement a download method for the files based on the media view mentioned above. This should be it.
I think this is the best and easiest way to control the access for such folders.
Due there are some limitations if it is not your server by post_max_size etc. you should maybe think about an external script (or write it on your own if you have the time ;)) to load those file over ftp.
You could also think about a folder accessible on your ftp to upload files. In the "new file" dialog in backend this folder will be outputted and you can include the file into the system by just copying it (via PHP of course). Advantage: only one upload (though it only be two if you are using the ftp upload method mentioned before this).
If you are just into sharing files with clients and those clients are not going to have access on anything else based in your cakephp project just use ftp with a folder for each client. Faster and easier to handle because you can send them urls like "ftp://username:password#yourserver.com" and done. They are logged in, they can view the html files due they are accessing the ftp via the browser and it should be noob safe.
Hope anything of this will feed your needs :)
Greetings
func0der