Skip to content
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

[REQ]: Restrict Uploaded File Name #9

Closed
robert1112 opened this issue Feb 16, 2023 · 19 comments
Closed

[REQ]: Restrict Uploaded File Name #9

robert1112 opened this issue Feb 16, 2023 · 19 comments
Assignees
Labels
enhancement New feature or request

Comments

@robert1112
Copy link

Is your feature request related to a problem? Please describe.
It is better to have predefined file name for better search in future.

Describe the solution you'd like

  1. Allow to use REGEX to define the name format.
  2. And Show Name Format on the front for the user to understand when upload or see the error why it is rejected.

Describe alternatives you've considered
No

Additional context
No

@robert1112 robert1112 added the enhancement New feature or request label Feb 16, 2023
@robert1112
Copy link
Author

Naming is crucial for all users, big or small. Thank you.

@kid1194
Copy link
Owner

kid1194 commented Feb 16, 2023

@robert1112 Thank you buddy for reaching out..

Let me get things straight..

You are suggesting a feature that only allows uploading files that matches a specific filename or regex? Am I right?

If that's what you are suggesting, then I how it can be done without causing problems and then implement it 😁

I will update you on the status of this feature..

Best regards

@robert1112
Copy link
Author

@kid1194 That is AWESOME. I am glad you have the idea already and willing to implement it. It will be a popular addon to your plugin anyway. Look forward to it.

@kid1194
Copy link
Owner

kid1194 commented Feb 20, 2023

@robert1112 I have implemented the feature and updated the plugin..

Can you please check if it's working or not..

And can you please also check if the plugin fully functional in web forms..

Best regards..

@robert1112
Copy link
Author

robert1112 commented Feb 22, 2023

@kid1194 Awesome. I was checking inbox from time to time to see if any progress. Until I check by myself. I will update you soon. Thank you for awesome support.

@kid1194
Copy link
Owner

kid1194 commented Feb 22, 2023

@robert1112 I will be patiently waiting for your update 😁

@robert1112
Copy link
Author

Hi @kid1194

  1. I cannot see Better Attach Options in attach or attach image fields. Same with newly created ones. This is my first time using this plugin. Is there something I missed?
  2. With the update, is it possible to use {field name} like doc ID in the naming rules? Here is the case. The uploaded files should contain the doc ID and ends with a fixed word. So the file name will be LEAD-203920A. "A" means Approved.

Thank you so much.

@robert1112
Copy link
Author

I read it on the other post.

DocField-better_attach_options is created but when I click in. There is the error on save.
https://share.cleanshot.com/yDnCrMGt

@kid1194
Copy link
Owner

kid1194 commented Feb 28, 2023

@robert1112 Thank you bro for reporting this..

BTW, you are not supposed to edit it directly..

Just edit the Attach or Attach Image field and you will find Better Attach Options bellow the default Options field..
There you put the plugin options..

Best regards..

@robert1112
Copy link
Author

Hi @kid1194

  1. I cannot see Better Attach Options in attach or attach image fields. Same with newly created ones. This is my first time using this plugin. Is there something I missed?
  2. With the update, is it possible to use {field name} like doc ID in the naming rules? Here is the case. The uploaded files should contain the doc ID and ends with a fixed word. So the file name will be LEAD-203920A. "A" means Approved.

Thank you so much.

@kid1194 Hi You probably miss this reply. I cannot find Better Attach Options. But I can see the custom field, though.

Also, with the update, is it possible to use {field name} like doc ID in the naming rules? Here is the case. The uploaded files should contain the doc ID and ends with a fixed word. So the file name will be LEAD-203920A. "A" means Approved.

Thank you so much for your support.

@kid1194
Copy link
Owner

kid1194 commented Mar 1, 2023

@robert1112 Sorry for the late reply..

I cannot find Better Attach Options. But I can see the custom field, though.

I have fixed this in the latest update. I forgot to set the module for the custom field..

Also, with the update, is it possible to use {field name} like doc ID in the naming rules?

Sadly no because the file name restriction is being processed in JavaScript and not in Python so such thing is not possible at the moment..

Based on your autoname, the file name regexp that you can use is /LEAD\\-([\\d]+)A/..

@kid1194
Copy link
Owner

kid1194 commented Mar 5, 2023

@robert1112 Hey bro..

Did the solution I suggested work for you or not?

Best regards..

@robert1112
Copy link
Author

@kid1194 Hi Thanks for the update. I am out of town for a vacation but I will test it soon and feedback here for sure.

Thanks for such awesome feature.

@kid1194
Copy link
Owner

kid1194 commented Mar 7, 2023

@robert1112 Take your time bro and enjoy your vacation 😁..

@kid1194 kid1194 closed this as completed Apr 3, 2023
@robert1112
Copy link
Author

@kid1194 Sorry for my late reply.

I still have problem finding Better Attach Options in attach or attach image fields. https://cln.sh/Khxl9xlQ

Here is the version:
ERPNext: v14.22.0 (version-14)
Frappe Framework: v14.33.0 (version-14)
Frappe Better Attach Control: v2.0.0 (main)

Thank you very much.

@kid1194
Copy link
Owner

kid1194 commented May 3, 2023

@robert1112 Ok, please do the following..

  1. Go to Custom Fields doctype
  2. Search for Better Attach Options
  3. If found, edit the field and check the box for Allow in Quick Entry
  4. If not found, You need to manually create the field

If the field isn't found then create a new custom field with the following values:

  • DocType: DocField
  • Label: Better Attach Options
  • Field Name: better_attach_options
  • Field Type: Small Text or Text or Long Text
  • Module: Frappe Better Attach Control
  • Depends on: eval:in_list(['Attach', 'Attach Image'], doc.fieldtype)
  • Insert After: options
  • Allow in Quick Entry: Yes

Best regards..

@robert1112
Copy link
Author

Hi @kid1194
I can find Better Attach Options in custom field and it has Allow in Quick Entry checked already. I saw the error below while opening the page: Custom Fields cannot be added to core DocTypes. Thank you.

Shot 2023-05-03 at 10 57 59

@kid1194
Copy link
Owner

kid1194 commented May 3, 2023

@robert1112 Apparently frappe doesn't allow adding custom fields to the core Doctype..

This will cause a problem for web forms which will make the plugin doesn't work except in Desk only..

I will make several changes and get back to you..

Thanks a lot buddy for your help..

Best regards..

@kid1194
Copy link
Owner

kid1194 commented May 5, 2023

@robert1112 Please check this comment #11 (comment).

Best regards..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants