-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make requestDate a parameter for presignedUrl #724
Comments
@dustin-H You can use either |
Hi @kannappanr, thanks, for the quick reply. When I set a header on the url a cache would save the file for a certain time period. However, this depends on the url including all GET-params. This will not work if a file has two signed urls issued at different dates. Example: One of them could look like this: (simplified)
Then I request the same data again at 9:01 AM, because something has updated (but not the image). I'll get the same image as presigned url:
Since the GET-parameters The caching of a browser can only be achieved by issuing the signature to the same Cheers, Dustin |
👍
This will be useful for everyone, please send the PR, thank you. |
Hi @krishnasrinivas,
Thanks! I just created the PR: #728 |
Because |
Hi @satanTime I don't understand how this breaks your your stuff. The change was an additional and optional parameter. As the method is checking for function-types (callback-method) the old signature should still work well. This is why a minor release is totally fine for me. |
Hi @dustin-H, I think that's the reason why you broke it :) In computer science any breaking change of public interface is one of the most horrible things, that's why people have minor and major versions and support old interfaces to keep backward compatibility for some period. That's why we also have LTS versions etc. The task you solved here could be done by extending minio client, instead of to change its source. And basically people, who're interested to have cached urls, could use new In our project we use exactly this approach. Imagine that you have class which extends In proper world your change should be next major version with warning about breaking unsupported change. |
Why do you explain computer science within a discussion at GitHub? You still have not delivered any example how this can break any Javascript Code. Criticising others by letting them look stupid is not the fine way. Btw.: This wasn't even my decision. |
I explain computer science within a discussion at GitHub because some people on GitHub don't know it. I mentioned an example above when someone extends import { Client, ResultCallback } from 'minio';
export class MyClient extends Client
{
async presignedUrl(
httpMethod: string,
bucketName: string,
objectName: string,
expiryOrCallback?: number | ResultCallback<string>,
reqParamsOrCallback?: { [key: string]: any; } | ResultCallback<string>,
possibleCallback?: ResultCallback<string>,
): Promise<string> {
console.log('forget about callback, now it is date object', possibleCallback);
return super.presignedUrl(httpMethod, bucketName, objectName);
}
} to trigger error: myClient.presignedGetObject("someBucket", "someDoc", 60 * 60 * 60); And check how it works with 7.0.1 and 7.0.5. About criticism and stupid - you say that, not me. |
Okey, now we are talking. The overriding itself isn't the single problem here. If you would use Root of this error is the use of the public method As Javascript-Developer I am not used to do OOP-Stuff like overriding that often. So I haven't even thought about the fact, that someone could extend this class and override some basic methods which are used within the super class. I think the person who released the version as minor change has also not seen this potential issue as this is kind of complex. Maybe we should make Anyway, sorry for breaking your code. |
Agree, there're a lot of possible solutions. I don't have problem with change itself, our code is already fixed. What I wanted to highlight here is breaking change under minor version. I hope now, everybody is aware about this and in future breaking changes will be processed and released in more smooth way. |
Interesting ... JS is a tricky language, If you see below, Go behaves as expected. We'll note this behavior for future minio-js releases.
|
Hi @krishnasrinivas, now to reproduce the issue change in your go |
@satanTime it works as expected (same result as before) |
ah, understood your example. Looks like goland isn't suitable here. In JS it's next: before change you should get "superclass firstFunc". |
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain on a related note for further reading. |
Hi there,
I'm using presigned urls pretty much in my projects. However, one problem is, that a client is reloading all images when it gets new urls. It is not cacheable by the browser as my server always responds new presigned urls with every request.
A solution would be to respond the same signed url within e.g. one day. So the client wouldn't get a new url with each and every request but instead one per day as it is cached.
However, a cache would need to store a lot of presigned urls, which I would like to avoid.
So I came to the idea of issuing all presigned urls to the beginning of the day. For example regardless of whether a file is requested at 9AM or 9PM, the server would respond a presigned url issued at 12AM (9 or 21 hours before). The signature would expire for example after 48 hours. This would respond the same presigned url on one day with every request.
To implement this, I need to set the
requestDate
in https://github.com/minio/minio-js/blob/master/src/main/minio.js#L1562.My suggestion would be to add an optional parameter (
requestDate
) to the functionspresignedUrl()
,presignedGetObject()
andpresignedPutObject()
.What do you think about that?
If you agree, I would create a PR.
Cheers, Dustin
The text was updated successfully, but these errors were encountered: