标签: store

Django Db 图像视频

如何通过 Django 将图像、视频和音频存储在 Mysql 数据库中?

我知道我可以存储图像、视频、音频的链接,或者图像、视频、音频本身。

但这到底是如何运作的呢?

我了解模型以及它们如何通过manage.py 创建表。但是有关于如何通过 Django 创建图像(例如 jpg、tiff 等)数据库的好教程吗?

谢谢

L。

database django store image

4
推荐指数
1
解决办法
8928
查看次数

将图像存储在变量中,稍后回显

假设我让用户输入图像的 URL。

在 URL 验证等之后,我想获取图像并将其存储在 PHP 变量中。不是图像路径,而是实际图像本身。

我在其他字符串之间添加了这个图像保持变量,所以header()在回显图像之前我不能改变使用。是否可以使用<img>HTML 标签?我真的不想将图像复制到我自己的服务器...

我如何能:

  1. 将图像存储在一个变量中,使得,
  2. 从变量中回显图像而不更改标题。

编辑:

我在上面说过我将此图像放入另一个变量中,例如:

$str = "blah blah" . $var_holding_img . "more text";
Run Code Online (Sandbox Code Playgroud)

是否可以在上面的字符串中插入一些将被图像替换的内容?可以$str稍后解析变量以用图像替换一些随机文本,如“abg30j-as”...

php variables store echo

4
推荐指数
1
解决办法
3万
查看次数

如何在 C++11 中存储任意方法指针?

我需要一种方法来存储方法指针列表,但我不在乎它们属于哪个类。我想到了这一点:

struct MethodPointer
{
    void *object;
    void (*method)(void);
};
Run Code Online (Sandbox Code Playgroud)

然后我可以有一个采用任意方法的函数:

template <typename T>
void register_method(void(T::*method)(void), T* obj) {
    MethodPointer pointer = {obj, method);

}

void use_method_pointer() {
    ...
    MethodPointer mp = ...

    // call the method
    (mp.object->*method)();

    ...
}
Run Code Online (Sandbox Code Playgroud)

这显然无法编译,因为我无法在 register_method() 中将方法指针转换为函数指针。

我需要这个的原因是因为我有一个可以发出事件的类 - 我希望任意实例订阅这些事件作为方法调用。这是可能的吗?

附注。适用条件: 1. 我不想使用 Boost 2. 我不想使用“侦听器”接口,其中订阅者必须对抽象接口类进行子类化。

感谢您的时间。

c++ store member-function-pointers list c++11

4
推荐指数
1
解决办法
1041
查看次数

MobX异步反应

嗨,我在商店中使用MobX,当计算值发生变化时,我需要进行异步反应:

class Store {
    @observable user;
    @observable something;

    @computed get firstParam () {
         return this.user && this.user.params[0];
    }

    async loadSomething () {
        reaction(
                () => this.firstParam,
                async (param) => {
                    const { data: something } = await axios.get(`url/${param}`);

                    runInAction('update state after fetching something', () => {
                        this.something = something;
                    });
                }
            );
     }

}
Run Code Online (Sandbox Code Playgroud)

我想知道使用when而不是reaction分开运行条件会有什么区别?

when(
    () => !!this.firstParam,
    async () => {
         // fetch using this.firstParam
    }
)
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous store mobx

4
推荐指数
1
解决办法
2282
查看次数

使用 Redux 更新整个状态的方法是什么?

我有一个空state对象,在应用程序启动时使用默认空字段实例化。

它包含一个名为 的空数组users

const state = {
                  users: []
              }
Run Code Online (Sandbox Code Playgroud)

在开始时,我向服务器发送一些命令,然后服务器发送数据作为响应。

由于我需要填充users,我想我只想用从服务器收到的新数组替换整个用户数组。

我读到,在 redux 中,您获取当前状态,对其应用一些更改并返回一个新状态。当我想更改用户密码时,这听起来不错,然后我会调用如下操作:

{
    action: 'CHANGE_PASSWORD',
    user: 'john',
    password: 'karamba',
}
Run Code Online (Sandbox Code Playgroud)

它将由调度程序管理,在调度程序中将john找到处于当前状态的用户,并且密码将被替换为新密码。

但这对于我想要加载一些初始数据的场景是否正确?

如果是这样,行动会是什么样子?

{
    action: 'FETCH_USERS'
}
Run Code Online (Sandbox Code Playgroud)

然后reducer会取代整个users数组?

javascript store redux

4
推荐指数
1
解决办法
6969
查看次数

Vuex 突变调用另一个突变或同步操作?

我正在学习 Vuex,但在构建我的应用程序时遇到了问题。

考虑这些代码片段,它们都在做同样的事情:

示例#1:

mutations: {
  add: function(state, employee) {
    state.employees.push(employee);
  },
  remove: function(state, index) {
    state.employees.splice(index, 1);
  }
},
actions: {
  generate: function(context) {
    context.commit('add', 'John Smith');
  }
}
Run Code Online (Sandbox Code Playgroud)

如果操作应该是异步的,那么这是错误的。

示例#2:

mutations: {
  add: function(state, employee) {
    state.employees.push(employee);
  },
  remove: function(state, index) {
    state.employees.splice(index, 1);
  },
  generate: function(state) {
    this.commit('add', 'John Smith');
  }
}
Run Code Online (Sandbox Code Playgroud)

我可以从另一个突变中调用一个突变吗?如果没有,那就太错误了。

示例#3:

mutations: {
  add: function(state, employee) {
    state.employees.push(employee);
  },
  remove: function(state, index) {
    state.employees.splice(index, 1);
  },
  generate: function(state) {
    state.employees.push('John Smith');
  }
}
Run Code Online (Sandbox Code Playgroud)

另一方面,这重复了逻辑 …

state store vue.js vuex

4
推荐指数
1
解决办法
9418
查看次数

Redux Store 仅订阅特定事件?商店订阅()

我想将一些用户数据保存到 localStorage 并且需要商店订阅状态更改,但我不想在每次状态更改时触发,而是仅在特定事件发生时触发,例如在我的情况下是 user_update 事件。

我可以通过任何方式让商店订阅特定事件而不是通用事件:

store.subscribe(()=>{

//save to local storage here

})
Run Code Online (Sandbox Code Playgroud)

好吧,非常感谢您的帮助:)

store persist local-storage reactjs redux

4
推荐指数
1
解决办法
4089
查看次数

在 NgRx 中强类型存储的目的是什么?

CoreModule 是一个急切加载的模块,包含应用程序启动时所需的状态。

import * as fromCore from './state/core.reducer';

@NgModule({
  ...
  imports: [
    StoreModule.forRoot({ core: fromCore.reducer }),
Run Code Online (Sandbox Code Playgroud)

DocumentModule 是一个延迟加载的模块。

import * as fromDocument from './state/document.reducer';

@NgModule({
  ...
  imports: [
    StoreModule.forFeature('document', fromDocument.reducer),
Run Code Online (Sandbox Code Playgroud)

DocumentComponent 注入存储。

import * as fromDocument from './state/document.reducer';

constructor(private store: Store<fromDocument.State>) { }
Run Code Online (Sandbox Code Playgroud)

fromDocument.State 扩展了“核心”状态。

import * as fromCore from '../../core/state/core.reducer';

export interface State extends fromCore.State {
    document: DocumentState;
}
Run Code Online (Sandbox Code Playgroud)

我发现这种方法随处可见,但我认为它没有任何好处。当我将其设置为 fromDocument.State 不扩展 fromCore.State 时,我仍然可以访问 DocumentComponent 中状态树的“核心”部分。

this.user$ = this.store.select(fromCore.getUser);
Run Code Online (Sandbox Code Playgroud)

通过将存储注入组件中,我始终可以访问完整的状态树,无论我如何输入存储。那么强类型存储的目的到底是什么?为什么不到处使用 Store<any> 呢?我与 store 对象交互的唯一方式是 store.select 和 store.dispatch,所以据我所知,没有打字优势?

store strong-typing angular

4
推荐指数
1
解决办法
1077
查看次数

Redux Persist TypeError:store.dispatch 不是函数

在学习教程时,我收到了 store.dispatch is not a function 错误。我在 stackoverflow 上搜索了一段时间,但似乎找不到任何错误。我缺少什么?

显示错误的图片 [1]:https://i.stack.imgur.com/AekWH.png

import {configureStore, combineReducers} from '@reduxjs/toolkit'
import cartReducer from './cartRedux'
import userReducer from './userRedux'
import {
  persistStore,
  persistReducer,
  FLUSH,
  REHYDRATE,
  PAUSE,
  PERSIST,
  PURGE,
  REGISTER,
} from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
  key: 'root',
  version: 1,
  storage,
}

const rootReducer = combineReducers({user: userReducer, cart: cartReducer})
const persistedReducer = persistReducer(persistConfig, rootReducer)

export const store = () => configureStore({
  reducer: persistedReducer,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      serializableCheck: {
        ignoredActions: …
Run Code Online (Sandbox Code Playgroud)

store redux react-redux react-hooks redux-toolkit

4
推荐指数
1
解决办法
5610
查看次数

ExtJS存储/网格重置

我有一个按钮,当单击时,将使用提供的URL创建一个JSONstore.然后将商店加载到网格中.如果再次单击该按钮,它会再次添加所有信息(因此会列出两次).我想要它,以便当用户点击按钮时,它会清除商店/网格,然后添加所有内容.

有关如何实现这一目标的任何想法?

谢谢,

编辑 ExtJS 3

datasetStore.removeAll();
datasetStore.loadData(datasetsArray);
Run Code Online (Sandbox Code Playgroud)

grid extjs store reset clear

3
推荐指数
1
解决办法
1万
查看次数