In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about the example analysis of django-mdeditor-pplus in Python. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
The ecology of Python is good. You can find open source solutions for almost anything you want, and code outside the business rarely needs to start from zero. Of course, not just python, other languages are very open, a lot of open source, but relatively more Python.
If the open source code does not meet the requirements, you only need to stand on the shoulders of giants to correct it. Needless to say, the benefits are naturally for convenience and experience, so you don't have to consider these image resources when the server is migrated. With the blessing of CDN in the cloud, the user experience will be much better.
Directly fork a code, the name is django-mdeditor-pplus, because plus is used, then my name is pplus.
In fact, there is not much code to add, that is, according to the configuration switch to determine whether to use oss to save pictures.
# save image
File_full_name ='% sails% s.% s'% (file_name
'{0:%Y%m%d%H%M%S%f}' .format (datetime.datetime.now ())
File_extension)
If MDEDITOR_CONFIGS.get ("OSS"):
# using Ali Cloud Storage
Import oss2
Auth = oss2.Auth (settings.OSS_ACCESS_KEY_ID, settings.OSS_ACCESS_KEY_SECRET)
Bucket = oss2.Bucket (auth, settings.OSS_ENDPOINT, settings.OSS_BUCKET_NAME)
Bucket.put_object (file_full_name, upload_image.read ())
Url = f "https://{settings.OSS_BUCKET_NAME}.{settings.OSS_ENDPOINT}/{file_full_name}"
Else:
With open (os.path.join (file_path, file_full_name), 'wb+') as file:
For chunk in upload_image.chunks ():
File.write (chunk)
Url = os.path.join (settings.MEDIA_URL
MDEDITOR_CONFIGS ['image_folder']
File_full_name)
Return JsonResponse ({'success': 1)
'message':' uploaded successfully!
'url': url})
Of course, you can also expand to support more platforms, such as Tencent Cloud, or cloud services such as Huawei and Qiniu.
Project address: https://github.com/lzjun567/django-mdeditor, welcome pull request or fork to continue to transform it.
When someone asks me how to master python or a framework?
My answer is that as long as you have the ability to solve problems independently, no matter what method you use to hold it, I think you have mastered the language.
In addition, do not say that you are "proficient". Once upon a time, I did not know that I had been "proficient". I wrote "proficiency" on my resume before graduation, and it turned out to be completely wrong. Fortunately, the older you get, the more you don't know.
The above is the example analysis of django-mdeditor-pplus in Python. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.