I am trying to use the amazon S3 versioning.
So I manage to create a object and display versions and select the version of a well Preci.
But I block or it is for public display url of a document versioning
s3 = Aws::S3::Client.new
prefix = "path/file"
obj = s3.list_object_versions(bucket: 'bucket', prefix: prefix)
I get the version and I want are public url
obj.versions.first
I can not find the method that allows me to have the public URL
Thank you
Per the docs, the version object (ie, what you get upon obj.versions.first) has a version_id key.
You can use that ID to get that version using REST - you just add a versionId=<THE_ID> to your query string.
But I'm not really sure that counts as a public URL. It probably needs you to be authenticated - I don't think it's a good idea to have every version of an object publicly accessible, so probably you just can't.
Thank you for your answer,
Actually my url is not secure, so I used a test url public but that does not work because it says access denied, and yet I added him:
#bucket = Aws::S3::Bucket.new(BUCKET)
url = #bucket.object(name)
url.public_url(acl: 'public-read')
So adding a new permission I manage to not have the access denied but now he told me that the file is not yet well I use the public_url,
I have forgotten something?
#bucket = Aws::S3::Bucket.new(BUCKET)
url = #bucket.object(#name)
url.public_url
Related
The Strapi API responds the media URLs as something like "url:'/uploads/thumbnail.png'".
I would like to get the complete URL that links to my file as value for "url". For example: "url:'https://example.org/uploads/thumbnail.png'"
The documentation also shows the full URL as response. How can I achieve this?
The full URLs come from using an upload provider such as AWS-S3 or Cloudinary. The local provider doesn't support full URLs at the moment.
There are some potentials reasons why you shouldn’t store a full URL, and respond with a full URL. I won’t dive into those reasons.
I suggest creating the entire request/response, or creating a middleware component to intercept the response.
Then you can modify the original url value with the site’s URL. Looping through the results with something like:
const serverHost = strapi.config.get('server.host', 'defaultValueIfUndefined');
url = serverHost + url;
See the following docs for more details:
https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations.html
https://docs.strapi.io/developer-docs/latest/development/backend-customization/middlewares.html#implementation
I have a host for my Laravel website and another (non-laravel) for stored files. Direct access to my files are blocked completely by default and I want to control access to them by creating temporary links in my Laravel site. I know how to code, just want to know the idea of how to do it (not details).
From the Laravel docs
Temporary URLs For files stored using the s3 or rackspace driver, you
may create a temporary URL to a given file using the temporaryUrl
method. This methods accepts a path and a DateTime instance specifying
when the URL should expire:
$url = Storage::temporaryUrl(
'file.jpg', now()->addMinutes(5)
);
You could also make your own solution by directing all image request through your own server and making sure the file visibility is set to private.
Here is an example of how a controller could return image from your storage
public function get($path)
{
$file = Storage::disk('s3')->get($path);
// Do your temp link solution here
return response($file, 200)->header('Content-Type', 'image/png');
}
What i am using right now is Flysystem provided in laravel.Laravel Flysystem integration use simple drivers for working with local filesystems, Amazon S3 and other some space provide also. So for this doesn't matter whether is a server is laravel server or not.
Even better, it's very simple in this to switch between server by just changing server configuration in API.
As far as I know we can create temporary Url for s3 and rackspace in this also by calling temporaryUrl method. Caching is already in this.
That's the thing.
If your files are uploaded on an AWS S3 server
then,
use Storage;
$file_path = "4/1563454594.mp4";
if( Storage::disk('s3')->exists($file_path) ) {
// link expiration time
$urlExpires = Carbon::now()->addMinutes(1);
try {
$tempUrl = Storage::disk('s3')->temporaryUrl($file_path, $urlExpires);
} catch ( \Exception $e ) {
// Unable to test temporaryUrl, its giving driver dont support it issue.
return response($e->getMessage());
}
}
Your temporary URL will be generated, After given expiration time (1 minute). It will expire.
I'm trying to figure something out. I want to make a page where a user can check for domain names and if they're available or not. I'm asking for advice because I don't know where to look. TransIP does have an API but I can't understand their documentation. What can I do? I want to make this work in laravel
There are many API wrappers you can grab from github, here is one I found on a google search. https://github.com/verschoof/transip-api
Just install with composer, put your login and private key in your .env perhaps and then include it in whatever file you want.
$client = new Transip\Client(env('TRANSIP_LOGIN'), env('TRANSIP_KEY'), true);
$domainApi = $client->api('domain');
$domainInfo = $domainApi->getInfo('user-input-domain.com');
$status = $domainApi->checkAvailability();
I would put env variables into a config file and access with config('key') but this is a basic example.
I try to migrate my project to aws-sdk 2. Need to use AWS SDK for Ruby - Version 2 for this.
I found all methods, but i cant change access to file (make public).
In later version i use this:
bucket.objects[file_path].acl = :public_read
But i cant find method for changing with new api version.
This is link to old api documentation
This is link to new api documentations
I presume here that you want to change the object ACL after it's been uploaded to S3. If you can, consider setting the ACL when the object is sent to S3 rather than after.
There's two ways to do it. They are both similar and perform the same action. Pick the one you like best or the one you are more comfortable with.
Using the Client API
client = Aws::S3::Client.new(region: myregion)
resp = client.put_object_acl({ acl: "public-read", bucket: mybucket, key: mykey })
Documentation:
http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#put_object_acl-instance_method
The Resource API
s3 = Aws::S3::Resource.new(region: myregion)
bucket = s3.bucket(mybucket)
object = bucket.object(mykey)
resp = object.acl.put({ acl: "public-read" })
Documentation:
http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/ObjectAcl.html#put-instance_method
Bonus
If absolutely all your objects inside your bucket needs to be public, you can set the default ACL on your whole bucket so that any object uploaded will be automatically public without having you to specify it. You do that by setting a bucket policy to your bucket.
Make a bucket public in Amazon S3
I am trying to localize Lenya publication URLs.
I store URL translation in the Document metadata and rewrite urls with URLRewriter transformator.
e.g. I build
/lenya/default/authoring/en/home
from
/lenya/default/authoring/index.html
But I can't find a simple way to force Lenya to tranlate incoming request URI back to the original path: /lenya/default/authoring/index.html
Really I want to process the request via pipelines using the original URL, not translated.
Is it possible at all? I had tried to add a servlet filter and use dispatcher, but filter can't access documents metadata because Environment object isn't in the processing stack yet at this stage...
(At this moment I see only one way - to update CocoonServlet and Cocoon classes)
Thanks!
I was able to do this via a RequestListener.
In the public void onRequestStart(Environment environment) method I create RequestWrapper with a new real URL and put it into objectModel. Also I change Environment context with a real URL: env.setContext("", realUrl, env.getContext())
This works fine!